当系统尝试启动时,liquibase不会响应

问题描述 投票:0回答:1

我正在尝试将liquibase集成到现有数据库(PostgreSQL)的现有项目中。

当我试图启动系统时,我没有看到liquibase试图做任何动作。

这是数据源bean:

<bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${jdbc.driverClassName}" />
        <property name="url" value="${jdbc.url.intguard}" />
        <property name="username" value="${jdbc.username.intguard}" />
        <property name="password" value="${jdbc.password.intguard}" />
    </bean>

LiquibaseCofing:

@ContextConfiguration
public class LiquibaseConfig {

    @Autowired
    private DataSource dataSource;

    @Bean
    public SpringLiquibase liquibase() {
    SpringLiquibase liquibase = new SpringLiquibase();
    liquibase.setChangeLog("classpath:/database/changelog.xml");
    liquibase.setDataSource(dataSource);
    return liquibase;
    }

}

liquibase-changelog.xml:

<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
         http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">

    <changeSet author="John" id="someUniqueId">
        <addColumn tableName="users">
            <column name="address" type="varchar(255)" />
        </addColumn>
    </changeSet>

</databaseChangeLog>

我知道系统启动时正在调用LiquibaseConfig bean,请帮我抓住我所遗漏的内容,谢谢。

java spring liquibase
1个回答
0
投票

我打赌你需要用SpringLiquibase.shouldRun(true)设置属性。

尝试调试方法SpringLiquibase#afterPropertiesSet()或至少尝试添加包liquibase.integration.spring的日志记录,以查看是否有关于调用的提及。

© www.soinside.com 2019 - 2024. All rights reserved.