![](/img/trans.png)
[英]Liquibase changelog does not exist - ChangeLogParseException
[英]Liquibase: receiving “file does not exist” exception when file exists for changelog.xml
我正在嘗試實現Java觸發的liquibase數據庫更新。
我有以下代碼:
java.sql.Connection connection = openConnection(eventContext);
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
String changelog = UpgradePanDatabase.class.getResource("/liquibase/db.changelog.xml").getPath();
Liquibase liquibase = new liquibase.Liquibase(changelog, new ClassLoaderResourceAccessor(), database);
liquibase.update(new Contexts(), new LabelExpression());
connection.close();
但我收到以下ChangeLogParseException:
/Users/ntregillus/myApp/.mule/apps/myApp/classes/liquibase/db.changelog.xml不存在
但是我知道文件存在,我可以復制路徑,然后直接從終端打開它,也可以在文件資源管理器中找到它。 為什么Liquibase無法找到該文件?
最可能的原因是變更日志未打包為jar文件中的資源。 檢查打包的jar的結構,而不是本地開發人員的工作副本。
UpgradePanDatabase.class.getResource( “/ liquibase / db.changelog.xml”)
它將搜索到“ UpgradePanDatabase” .class
檢查Absolute_path_of_FolderContaing_UpgradePanDatabase.class + /liquibase/db.changelog.xml>是否與您的IDE中的相同。
但是在您的情況下,應該是“ classes”文件夾的Wrt。嘗試使用SOP調試-“ String changelog”怎么說。 這可能會有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.