Ser*_*gii 4 java sql-server liquibase spring-data-jpa
我需要配置changeSet 执行从jar 加载的sql。
我有changeSet可以正常工作的内部项目
<changeSet id="1" author="sergii" dbms="h2">
<sqlFile
encoding="utf8"
path="schema-ms-sql.0.0.1.sql"
relativeToChangelogFile="true"
splitStatements="true"
stripComments="true"/>
</changeSet>
Run Code Online (Sandbox Code Playgroud)
有些脚本是从不同的库提供的(在我的例子中是spring-boot-starter-batch),例如:
classpath:/org/springframework/batch/core/schema-h2.sql
Run Code Online (Sandbox Code Playgroud)
请注意,jar 位于项目中并且可访问(构建\测试\运行时)。因此,我还需要在我的 中注册一个changeSet,尝试:
<changeSet id="2" author="sergii" dbms="h2">
<sqlFile
encoding="utf8"
path="classpath*:/org/springframework/batch/core/schema-h2.sql"
relativeToChangelogFile="true"
splitStatements="true"
stripComments="true"/>
</changeSet>
Run Code Online (Sandbox Code Playgroud)
它不适用于任何配置(如"classpath:/org/springframework/batch/core/schema-h2.sql"、"/org/springframework/batch/core/schema-h2.sql"、等),"org/springframework/batch/core/schema-h2.sql"因为"classpath*:/org/springframework/batch/core/schema-h2.sql"
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.UnexpectedLiquibaseException: java.io.IOException: File does not exist: 'classpath*:/org/springframework/batch/core/schema-h2.sql'
Run Code Online (Sandbox Code Playgroud)
我知道使用 spring 我可以使用自动配置,但我对 liquibase 审核感兴趣......
有什么想法如何使打包脚本通过 liquibase 审计工作changeSet或包含到 liquibase 审计中吗?
解决方案是更改sqlFile标签的属性:
relativeToChangelogFile="false"
Run Code Online (Sandbox Code Playgroud)
结果changeSet如下:
<changeSet id="2" author="sergii" dbms="h2">
<sqlFile
encoding="utf8"
path="classpath:/org/springframework/batch/core/schema-h2.sql"
relativeToChangelogFile="false"
splitStatements="true"
stripComments="true"/>
</changeSet>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5271 次 |
| 最近记录: |