我的项目中有一个 Spring 配置 java 文件(即带有 @Configuration
注释)。现在我正在创建一个 SpringLiquibase
的 bean在这个类(class)。变更日志的主要文件,即 db.changelog.xml
文件在资源文件夹中。所以可以直接从 resources
访问它文件夹,如果我使用 springLiquibaseObj.setChangeLog("classpath:db.changelog.xml");
方法。但是当我尝试从 db.changelog.xml
访问其他 xml 文件时文件
<include file="src/main/config/db/db.changelog-main.xml" />
我收到找不到文件夹和文件的错误消息。
在这里,我想保留db.changelog.xml
文件在 resources
config
中的文件夹和所有其他新的更新日志文件应与 resources
处于同一级别的文件夹.原因是,在resources
文件夹,包有这样的文件夹结构config/1.0.0
被视为 config/1/0/0
我不想要。
有什么方法可以用我项目中的当前设置来实现这种结构(如下所示)?
- config
- 1.0.0
- db.changelog.201412120101.xml
- 1.1.0
- 2.0.0
- resources
- db.changelog.xml
或
- config
- 1.0.0
- db.changelog.201412120101.xml
- 1.1.0
- 2.0.0
- db.changelog.xml
- resources
最佳答案
我找到了解决方案。在此之前,我复制了文件夹 src/main/config
进入src/main/resouces
在 netbeans 中,因此将该文件夹作为包。所以文件夹名称 - config/db/1.0.0
变成了config/db/1/0/0
,但是当我在 resources
中创建新文件夹时文件夹,它工作正常,文件夹中的所有文件 1.0.0
可以正确访问。现在,我的文件夹结构是这样的:
- resources
- config
- db
- 1.0.0
- db.changelog.201412120101.xml
- 1.1.0
- 2.0.0
- db.changelog.xml
我可以访问 db.changelog.xml
来 self 的 Spring 类的文件,
springLiquibaseObj.setChangeLog("classpath:db.changelog.xml");
和来自 db.changelog.xml
的其他更新日志文件文件为,
<include file="classpath:config/db/1.0.0/db.changelog-201412120101.xml" relativeToChangelogFile="false" />
.
关于java - Spring 配置文件中的 Liquibase 文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21546433/