Java – using the liquibase file path through Maven and spring

I use the following bean to update the schema and initial data in the spring context:

<bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase">
    <property name="dataSource" ref="dataSource" />
    <property name="changeLog" value="classpath:db/changelog/db.changelog-master.xml" />
    <property name="dropFirst" value="true" />
</bean>

I also use Maven liquid plug-in to generate SQL scripts to view the created tables, etc

<plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>2.0.5</version>
                <configuration>
                    <!--mvn initialize liquibase:updatesql-->
                    <propertyFile>src/main/resources/db/config/liquibase-gensql-data-access.properties</propertyFile>
                    <changeLogFile>src/main/resources/db/changelog/db.changelog-master.xml</changeLogFile>

                </configuration>
           </plugin>

db. changelog-master. XML files include sub - level update files The question is how to quote them from the owner When I use spring, I must use the following path through classpath:

<include file="classpath:/db/changelog/db.changelog-1.0.xml"/>

When Maven is used, the path is:

<include file="src/main/resources/db/changelog/db.changelog-1.0.xml"/>

I want to set the same configuration for both cases How to archive?

Solution

I comment on Igor's answer. His solution doesn't seem to work

To solve this problem, I just pushed the patch to liquibase: https://github.com/liquibase/liquibase/pull/187. This should be in 3.0 6-snapshot merged, so in 3.0 6 will soon be available

With this change, you can now configure spring liquibase with this additional row:

<property name="ignoringClasspathPrefix" value="true" />

Another example / usecase that requires this change can be found here: https://github.com/LateralThoughts/spring-liquibase-extensions.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>