【发布时间】:2018-11-01 19:53:53
【问题描述】:
我创建了一个 JHipster 项目。我想手动运行 liquibase 变更集。默认情况下,变更集包含在类路径中。变更日志在src/main/resources/config/liquibase/master.xml,变更集在src/main/resources/config/liquibase/changelog。
<?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.5.xsd">
<include file="classpath:config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
</databaseChangeLog>
运行mvn liquibase:update 时,我收到一个错误,因为即使文件存在,更改集也不在类路径中:
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:update (default-cli) on project playground: Error setting up or running Liquibase: liquibase.exception.SetupException: classpath:config/liquibase/changelog/00000000000000_initial_schema.xml does not exist -> [Help 1]
所以我尝试通过设置类路径从命令行运行。
liquibase --classpath=src/main/resources --classpath=postgresql-42.1.3.jar
--url=jdbc:postgresql://localhost:5432/playground
--driver=org.postgresql.Driver
--changeLogFile=src/main/resources/config/liquibase/master.xml
--username playground --password=***** update
同样的错误:Unexpected error running Liquibase: classpath:config/liquibase/changelog/00000000000000_initial_schema.xml does not exist
一种解决方法是删除包含部分中的引用classpath:,但我想避免在使用jhipster entity 或jhipster import-jdl 时每次由jhipster 添加变更集时编辑文件。
【问题讨论】:
-
你能设置两次classpath吗?我看到两个
--classpath标志。另请注意,昨天已更改,并且在 JHipster 的未来版本中将删除类路径 github.com/jhipster/generator-jhipster/pull/6121 -
我放了两个
--classpath,因为我找不到单个--classpath的语法。我尝试使用;分隔符但没有用。看来删除classpath:将是未来的解决方案