Syd*_*ney 1 liquibase jhipster
我创建了一个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>
Run Code Online (Sandbox Code Playgroud)
运行时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]
Run Code Online (Sandbox Code Playgroud)
因此,我尝试通过设置类路径从命令行运行。
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
Run Code Online (Sandbox Code Playgroud)
具有相同的错误: Unexpected error running Liquibase: classpath:config/liquibase/changelog/00000000000000_initial_schema.xml does not exist
一种解决方法是删除classpath:包含部分中的引用,但是我希望避免每次使用jhipster entity或时jhipster添加变更集时都编辑文件jhipster import-jdl。
解决方案是mvn process-resources在运行liquibase命令之前运行,因此下面的文件src/main/resources将在该target/classes文件夹中。然后classpath:按照https://github.com/jhipster/generator-jhipster/pull/6121中的说明删除该部分