微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。