`我已經在運行專案并嘗試在專案中間引入 liquibase。這是基于 Spring Boot Maven 的專案。
我正在遵循步驟。
1.liquibase.properties
url=jdbc:postgresql://localhost:5432/cc
username=postgres
password=deadline123
driver=org.postgresql.Driver
outputChangeLogFile=src/main/resources/db/changelog/db.changelog-master.yaml
runOnChange=true
referenceUrl=jdbc:postgresql://localhost:5432/cc
referenceUsername=postgres
referencePassword=deadline123
changelogFile=src/main/resources/db/changelog/db.changelog-master.yaml
diffChangeLogFile=src/main/resources/diff.yaml
- 運行命令以生成當前資料庫狀態的更改日志
mvn liquibase:generateChangeLog - 然后運行命令同步更改日志并在資料庫中創建條目
mvn liquibase:changelogSync - 啟動我的應用程式,但它拋出錯誤關系已經存在。我不明白為什么 liquibase 正在執行已經執行的變更集?我正在使用 liquibase 4.6.3
uj5u.com熱心網友回復:
Liquibase 不會將更改與您的實際表進行比較,它只會跟蹤已執行的更改集(它會為名為 的表創建另一個表databasechangelog)。
話雖如此,您必須確保 liquibase 執行您的變更集,前提條件是“如果有任何失敗,請將其標記為已執行”。可以這樣實作:
<preconditions onFail="MARK_RAN">
<not>
<tableExists tableName="person"/>
</not>
</preconditions>
此示例以及更多資訊可以在https://www.liquibase.com/blog/adding-liquibase-on-an-existing-project上找到
uj5u.com熱心網友回復:
問題出在檔案路徑上 src/main/resources/db/changelog/db.changelog-master.yaml
liquibase:changelogSync如上所述在日志同步中添加檔案路徑,并且liquibae在開始時實際上需要classpath classpath:/db/changelog/db.changelog-master.yaml
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/407147.html
標籤:
