我尝试使用Liquibase的命令行工具和.war
文件在MySQL数据库上运行更新,并且不要触摸{{1}这一点非常重要除非我绝对不必破坏与maven和Jhipster一起运行的项目。
关于如何设置路径的the official documentations's example:
master.xml
我将liquibase.properties设为如下:
java -jar liquibase.jar \
--driver=oracle.jdbc.OracleDriver \
--classpath=website.war \
--changeLogFile=com/example/db.changelog.xml \
--url=jdbc:oracle:thin:@localhost:1521:oracle \
--username=scott \
--password=tiger \
update
我的url=jdbc:mysql://localhost:3306/databasename?useUnicode=true&characterEncoding=utf8&useSSL=false&createDatabaseIfNotExist=true
username=username
password=password
driver=com.mysql.jdbc.Driver
classpath=target/application-0.0.1-SNAPSHOT.war
changeLogFile=src/main/resources/config/liquibase/master.xml
看起来像这样:
master.xml
我的命令行命令如下所示:
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<include file="classpath:config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/>
</databaseChangeLog>
当我运行时,我收到以下错误:
liquibase --defaultsFile=../dev.properties update
当然没有任何事情发生。 Liquibase运行它的启动就好了,所以数据库中有Unexpected error running Liquibase: java.lang.IllegalArgumentException: name
表。
我已尝试将DATABASECHANGELOGLOCK
属性编辑为以下内容:
changeLogFile
但是,这些返回相同的错误消息。如果我尝试使用我的系统上的确切路径来更改文件,我当然得到这个:
changeLogFile=/home/user/project_src/src/main/resources/config/liquibase/master.xml
changeLogFile=WEB-INF/classes/config/liquibase/master.xml
我还尝试编辑Unexpected error running Liquibase: /home/user/project_src/~/project_src/src/main/resources does not exist
SEVERE 5/19/17 9:38 AM: liquibase: /home/user/project_src/~/project_src/src/main/resources does not exist
liquibase.exception.CommandLineParsingException: /home/user/project_src/~/project_src/src/main/resources does not exist
at liquibase.integration.commandline.Main.configureClassLoader(Main.java:828)
at liquibase.integration.commandline.Main.run(Main.java:187)
at liquibase.integration.commandline.Main.main(Main.java:103)
以使include标记看起来像这样:
master.xml
这适用于命令行工具,但由于这也是通过maven和Jhipster运行的,因此除非必须,否则不要操作此文件。
所有提及的技术都是他们的最新稳定版本,我在Ubuntu 16.10和17.04上遇到过这个问题。
如果我直接放置一个更改文件路径而不是<include file="changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="true"/>
,它会与以上列出的路径的任何一个版本完美地运行,但是我必须运行每个路径手动更改日志会完全失去master.xml
及其master.xml
标记的点。
该项目是使用Jhipster生成的。