Springboot Liquibase AWS Aurora 数据库应用程序启动问题

问题描述

我有一个现有的 Spring Boot 应用程序,我需要使用 liquibase 连接到 aurora DB 并创建表。我已经添加了所有必需的步骤,如下所示,但是当应用程序被部署时,没有看到任何特定于 liquibase 的日志,并且没有执行 changeSet。请帮忙调试问题。

1.db.changelog-master.xml(在 resources/db/changelog 下创建)

  <preConditions>
    <not>
      <tableExists tableName="table1"/>
    </not>
  </preConditions>
  <changeSet id="1" author="name">
    <createTable tableName="category">
      <column name="id" type="int" autoIncrement="true">
        <constraints primaryKey="true" nullable="false"/>
      </column>
      <column name="name" type="varchar(250)">
        <constraints unique="true" nullable="false"/>
      </column>
    </createTable>
  </changeSet>
</databaseChangeLog>
  1. application.properties
#Liquibase configuration
spring.datasource.driver-class-name=com.MysqL.jdbc.Driver
spring.datasource.url=jdbc:MysqL://aws-aurora-conn-url:3306/database-name
spring.datasource.username=usename
spring.datasource.password=password
spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml
spring.liquibase.enabled=true

  1. build.gradle 添加了这些依赖项
  implementation 'org.liquibase:liquibase-core'
  implementation 'MysqL:mysql-connector-java'

提前致谢

解决方法

问题是由于先决条件检查失败。在 db.changelog-master.xml 中添加了条件检查并能够连接它。这不会使应用程序实例失败,而是记录它并继续

  <preConditions onFail="WARN">
    <not>
      <tableExists tableName="table1"/>
    </not>