我創建了一個JHipster項目。我想手動運行liquibase變更集。默認情況下,更改集包含在類路徑中。更新日誌位於src/main/resources/config/liquibase/master.xml
,更改集位於src/main/resources/config/liquibase/changelog
。如何設置liquibase類路徑
<?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]
所以我嘗試在命令行設置classpath中運行。
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加入時間來編輯文件或jhipster import-jdl
。
您可以設置類路徑兩次嗎?我看到兩個'--classpath'標誌。另外請注意,這是昨天改變和類路徑將在JHipster的未來版本中刪除https://github.com/jhipster/generator-jhipster/pull/6121 –
我把兩個'--classpath'因爲我找不到單個'--classpath'的語法。我用';'分隔符嘗試,但沒有工作。似乎刪除'classpath:'將成爲未來的解決方案 – Sydney