我只想为Mysql数据库生成SQL脚本。为此,我使用了带有udateSql目标的maven液化基插件:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.0.5</version>
<configuration>
<propertyFile>src/main/resources/liquibase/liquibase.properties</propertyFile>
</configuration>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>updateSQL</goal>
</goals>
</execution>
</executions>
</plugin>这对于配置为访问已经运行的liquibase.properties服务器的MySql文件很好:
#liquibase.properties
driver: com.mysql.cj.jdbc.Driver
classpath: lib/mysql-connector-java-5.0.5-bin.jar
url:jdbc:mysql://localhost:3306/mydb?createDatabaseIfNotExist=true
username: root
password: pass
changeLogFile:changelog-master.xml
logLevel: finest但是,我只想生成脚本,而不需要运行DB的。为此,我想使用脱机数据库功能。从理论上讲,这样的liquibase.properties就足够了:
#liquibase.properties
url:offline:mysql?catalog=mydb
changeLogFile:changelog-master.xml
logLevel: finest然而,如果我这样做,它会抱怨没有设置一个司机。如果我像以前那样加上司机:
#liquibase.properties
driver: com.mysql.cj.jdbc.Driver
classpath: lib/mysql-connector-java-5.0.5-bin.jar
url:offline:mysql?catalog=avisporra
username:null
password:null
changeLogFile:changelog-master.xml
logLevel: finest我得到了下一个错误:
liquibase.exception.DatabaseException: Connection could not be created to offline:mysql?catalog=mydb with driver com.mysql.cj.jdbc.Driver. Possibly the wrong driver for the given database URL 我是不是遗漏了一些关于如何使用离线URL的内容?(谢谢你的帮助:)
发布于 2019-09-29 19:22:49
所以问题在于我正在使用的插件版本。我从Maven插件的液化库文档中复制了插件配置,不幸的是,它从插件中指定了一个旧版本(版本3.0.5)。离线url已在3.1中添加。因此,只要将插件版本更改为最新版本(现在是3.6.1版),离线网址就可以正常工作了。因此,在pom.xml中,插件版本应该如下所示:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<propertyFile>src/main/resources/liquibase/liquibase.properties</propertyFile>
</configuration>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>updateSQL</goal>
</goals>
</execution>
</executions>
</plugin>liquibase.properties是这样的:
#liquibase.properties
url:offline:mysql
changeLogFile:changelog-master.xml
logLevel: finest这样,它将在/target/liquibase下生成SQL脚本,而不需要运行MySql服务器。
https://stackoverflow.com/questions/58152803
复制相似问题