找不到数据库驱动程序:org.postgresql.driver

找不到数据库驱动程序:org.postgresql.driver,postgresql,maven,liquibase,Postgresql,Maven,Liquibase,我试图通过用Liquibase升级一个项目来改变它。这是一个JavaEE项目。所以我用的是liquibase maven插件 到目前为止,我的pom.xml中有: <plugin> <groupId>org.liquibase</groupId> <artifactId>liquibase-maven-plugin</artifactId>

我试图通过用Liquibase升级一个项目来改变它。这是一个JavaEE项目。所以我用的是liquibase maven插件

到目前为止,我的pom.xml中有:

            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>2.0.5</version>
                <configuration>
                    <propertyFileWillOverride>true</propertyFileWillOverride>
                    <propertyFile>src/main/resources/liquibase.properties</propertyFile>
                    <changeLogFile>src/main/resources/changelogs/changelog.xml</changeLogFile>
                </configuration>
                <executions>
                    <execution>
                        <!--  Another Error: plugin execution not covered by lifecycle configuration..-->
                        <!-- <phase>process-resources</phase> <goals> <goal>update</goal> </goals> -->
                    </execution>
                </executions>
            </plugin>
但是它没有驱动程序的类路径。我也需要类路径吗

changelog.xml有一个简单的变更集,它创建一个表,只是为了从一开始就测试liquibase

但是我没有走这么远,因为当我和

mvn liquibase:update
我收到这个错误:

[错误]无法在项目上执行目标组织。liquibase:liquibase maven插件:2.0.5:更新(默认cli):设置或运行liquibase:java.lang.RuntimeException时出错:找不到数据库驱动程序:org.postgresql.driver

我看不出重点。。该驱动程序以前已用于该项目。那么为什么液化者找不到它呢

编辑

当我通过添加驱动程序标记在pom.xml中编辑配置时,它会起作用:

            <configuration>
                <propertyFileWillOverride>true</propertyFileWillOverride>
                <propertyFile>src/main/resources/liquibase.properties</propertyFile>
                <changeLogFile>src/main/resources/changelogs/changelog.xml</changeLogFile>
                <driver>org.postgresql.Driver</driver>
            </configuration>

真的
src/main/resources/liquibase.properties
src/main/resources/changelogs/changelog.xml
org.postgresql.Driver
在此之前,我的驱动程序是在liquibase.properties中指定的,它实际上也应该可以工作

如果我想将驱动程序保存在属性文件中,也许有人可以告诉我liquibase.properties文件应该是什么样子。

编辑:

通过更换
解决了问题
driver:org.postgresql.driver
与liquibase.properties文件中的
driver=org.postgresql.driver


原始答案:

您已添加postgresql驱动程序作为Web应用程序的依赖项。但是当maven插件运行时,它们有自己的类路径,这与您的webapp不同。因此,插件本身需要包含对JDBC驱动程序的依赖性(这同样适用于其他插件,例如jetty maven插件):


org.liquibase
liquibase maven插件
2.0.5
真的
src/main/resources/liquibase.properties
src/main/resources/changelogs/changelog.xml
postgresql
postgresql
9.1-901-1.jdbc4

以下插件配置对我很有用

         <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>3.5.0</version>
            <configuration>
            <propertyFile>src/main/resources/liquibase.properties</propertyFile>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>update</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

org.liquibase
liquibase maven插件
3.5.0
src/main/resources/liquibase.properties
更新

不,这不是问题所在。即使我再次添加,错误仍然会出现。但是谢谢你的建议。奇怪的是,我刚刚使用属性文件尝试了你的示例,它很好地为我选择了驱动程序(即使没有在插件中指定对postgres的依赖)。也许可以尝试从本地maven repo中删除postgres JAR和liquibase插件,以便重新下载?还可以尝试使用“=”,
driver=org.postgresql.driver
指定驱动程序。否则我就没主意了,对不起!谢谢当某些东西起作用或不起作用时,我真的很恼火,我不明白为什么。它只是简单的
:“
而不是
driver=org.postgresql.driver
中的
”=“
。再次感谢
            <configuration>
                <propertyFileWillOverride>true</propertyFileWillOverride>
                <propertyFile>src/main/resources/liquibase.properties</propertyFile>
                <changeLogFile>src/main/resources/changelogs/changelog.xml</changeLogFile>
                <driver>org.postgresql.Driver</driver>
            </configuration>
<plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>2.0.5</version>
    <configuration>
        <propertyFileWillOverride>true</propertyFileWillOverride>
        <propertyFile>src/main/resources/liquibase.properties</propertyFile>
        <changeLogFile>src/main/resources/changelogs/changelog.xml</changeLogFile>
    </configuration>
    <executions>
        <execution>
            <!--  Another Error: plugin execution not covered by lifecycle configuration..-->
            <!-- <phase>process-resources</phase> <goals> <goal>update</goal> </goals> -->
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.1-901-1.jdbc4</version>
        </dependency>
    </dependencies>
</plugin>
         <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>3.5.0</version>
            <configuration>
            <propertyFile>src/main/resources/liquibase.properties</propertyFile>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>update</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>