【问题标题】:Springboot Liquibase AWS Aurora DB Application Startup issueSpringboot Liquibase AWS Aurora DB 应用程序启动问题
【发布时间】:2021-05-12 15:03:33
【问题描述】:

我有一个现有的 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'

提前致谢

【问题讨论】:

    标签: spring-boot liquibase amazon-aurora liquibase-sql


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 2021-08-28
      • 1970-01-01
      • 2022-06-19
      • 1970-01-01
      • 1970-01-01
      • 2015-09-23
      相关资源
      最近更新 更多