springboot集成liquibase来实现数据库版本管理

bootstrap.yml里加上下面配置从而使用xml格式的配置文件(觉得xml强大些)

liquibase:
  enabled: true
  change-log: classpath:/db/changelog/db.changelog-master.xml

当然,指定的位置xml文件是需要存在的

<?xml version="1.0" encoding="UTF-8"?>

<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 id="8" author="Qbit">
        <sql></sql>
</changeSet>
</databaseChangeLog>

用sql的方式比较简单,缺点是貌似不能执行sp的创建

一般id我会取行号,而author取微服务名字

当然maven也是需要加上

<dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
            <version>3.5.3</version>
        </dependency>
启动的时候liquibase会执行sql并且满足并发的情况

猜你喜欢

转载自blog.csdn.net/u012220365/article/details/80569906