Using liquibase file paths via both maven and spring
I think if you change your Maven path from
<changeLogFile>src/main/resources/db/changelog/db.changelog-master.xml</changeLogFile>
to
<changeLogFile>db/changelog/db.changelog-master.xml</changeLogFile>
and update db.changelog-master.xml file for all included files to use path relative to src/main/resources directory, it will fix the problem.
I solved this problem by using the same path to changeLog files in Spring, maven and integration test which call Liquibase. All my changelog files are located under /src/main/resources/db directory in one of the Maven modules within a project.
Maven profile which runs Liquibase, notice path: db/masterChangeLog.xml
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>*** Install a last major release version of db ***</id>
<phase>process-resources</phase>
<goals>
<goal>update</goal>
</goals>
<configuration>
<changeLogFile>db/masterChangeLog.xml</changeLogFile>
<contexts>dbBuildContext, dmlDevContext</contexts>
<propertyFile>db/liquibase-${user.name}.properties</propertyFile>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
<logging>debug</logging>
</configuration>
</execution>
db/masterChangeLog.xml file includes these files:
<include file="db/install.xml"/>
<include file="db/update.xml"/>
db/install.xml file includes other changelog files (so does update.xml):
<includeAll path="db/install/seq"/>
<includeAll path="db/install/tab"/>
<includeAll path="db/install/cst"/>
<includeAll path="db/latest/vw" />
Spring context executes the same set of db scripts upon app startup as follows:
<bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase">
<property name="dataSource" ref="baseCostManagementDataSource" />
<property name="changeLog" value="classpath:db/masterChangelog.xml" />
<property name="contexts" value="dbBuildContext, dmlDevContext" />
</bean>
I commented on Igor's answer, his solution does not seem to work.
In order to solve this, I just pushed a patch to Liquibase: https://github.com/liquibase/liquibase/pull/187. This should be merged in 3.0.6-SNAPSHOT and therefore shortly available in 3.0.6.
With this change, you can now configure SpringLiquibase
with this additional line:
<property name="ignoringClasspathPrefix" value="true" />
Another example/usecase requiring this change can be found here: https://github.com/LateralThoughts/spring-liquibase-extensions.