use*_*413 9 postgresql liquibase maven
我试图用Liquibase升级它来改变一个项目.它是一个Java EE项目.所以我使用liquibase-maven-plugin.
到目前为止我在我的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>
Run Code Online (Sandbox Code Playgroud)
其中已包含一个驱动程序:
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
liquibase.properties文件包含url,username,password,changeLogFile-Path和驱动程序:
#liquibase.properties
driver: org.postgresql.Driver
Run Code Online (Sandbox Code Playgroud)
但它没有驱动程序的类路径.我也需要类路径吗?
changelog.xml有一个简单的变更集,可以创建一个表,只是为了测试liquibase的开头.
但是我到目前为止还没来,因为当我用这个项目运行时
mvn liquibase:update
Run Code Online (Sandbox Code Playgroud)
我得到这个错误:
[错误]未能执行目标org.liquibase:项目PROJECT更新(默认CLI):liquibase - Maven的插件:2.0.5错误设置或运行Liquibase:了java.lang.RuntimeException:找不到数据库驱动程序:组织.postgresql.Driver
我看不出这一点..驱动程序已经在项目之前使用过了.那么为什么liquibase找不到呢?
编辑
当我通过添加驱动程序标记在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>
Run Code Online (Sandbox Code Playgroud)
之前我的驱动程序是在liquibase.properties中指定的,它实际上应该也可以.
也许有人可以告诉我如果我想将驱动程序保存在属性文件中liquibase.properties文件应该是什么样子.
Bar*_*man 12
您已将postgresql驱动程序添加为您的webapp的依赖项.但是当maven插件运行时,它们有自己的类路径,这与您的webapp不同.因此,您需要为插件本身包含对JDBC驱动程序的依赖(同样适用于其他插件,例如jetty-maven-plugin):
<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>
Run Code Online (Sandbox Code Playgroud)
编辑:
通过在liquibase.properties文件中替换
driver: org.postgresql.Driver
来解决该问题driver=org.postgresql.Driver
.
归档时间: |
|
查看次数: |
16485 次 |
最近记录: |