Spring Boot执行器“public.databasechangelog”不存在

时间:2016-12-30 14:19:02

标签: spring spring-boot liquibase

在我的Spring Boot项目中,我配置了Actuator端点。我想使用/liquibase端点来检查Liquibase迁移状态,但收到以下异常:

org.postgresql.util.PSQLException: ERROR: relation "public.databasechangelog" does not exist

这是因为我已经重新配置了我的项目,使用system PostgreSQL模式用于技术Liquibase表而不是public

如何告诉执行人员查看system架构而不是public

已更新

我已按以下方式配置Liquibase:

@Configuration
public class LiquibaseConfig {

    @Value("${liquibase.context}")
    private String context;

    @Value("${system.schemaName}")
    private String schemaName;

    @Autowired
    private DataSource dataSource;

    @Bean
    @DependsOn(value = "loggerProperties")
    public SpringLiquibase liquibase() {
        SpringLiquibase liquibase = new SpringLiquibaseExt(schemaName);

        liquibase.setContexts(context);
        liquibase.setDataSource(dataSource);
        liquibase.setChangeLog("classpath:changelog/db.changelog.xml");

        return liquibase;
    }

    private static class SpringLiquibaseExt extends SpringLiquibase {

        private String schemaName;

        public SpringLiquibaseExt(String schemaName) {
            this.schemaName = schemaName;
        }

        @Override
        protected Database createDatabase(Connection c, ResourceAccessor resourceAccessor) throws DatabaseException {
            Database database = super.createDatabase(c, resourceAccessor);
            database.setLiquibaseSchemaName(schemaName); //schema = system

            return database;
        }

    }
}

0 个答案:

没有答案