I need configure changeSet executing sql loaded from jar.
I have internal project changeSet
that works correctly
<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>
Some scripts are provided from different libraries (in my case it is spring-boot-starter-batch
), for example:
classpath:/org/springframework/batch/core/schema-h2.sql
Note that jar is in the project and accessible (build \ test\ run times).
As result I need register one also into my changeSet
, trying:
<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>
and it doesn't work with any configuration (like "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"
and so on) because of
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'
I know using spring I could use auto configuration, but I'm interested in liquibase auditing...
Is any ideas how to make packaged scripts working via changeSet
or include into liquibase auditing?
Solution is to change attribute for sqlFile
tag:
relativeToChangelogFile="false"
Result changeSet
below:
<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>