繁体   English   中英

Liquibase:当changelog.xml存在文件时,收到“文件不存在”异常

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM