【问题标题】:liquibase won't respond when the system trying to boot系统尝试启动时,liquibase 不会响应
【发布时间】:2019-02-21 22:13:36
【问题描述】:

我正在尝试将 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】:

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

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

    【讨论】:

    • 这个属性不是默认true吗?
    猜你喜欢
    • 1970-01-01
    • 2016-05-26
    • 1970-01-01
    • 2018-07-02
    • 1970-01-01
    • 2020-02-29
    • 1970-01-01
    • 1970-01-01
    • 2017-08-14
    相关资源
    最近更新 更多