本文来说下springboot整合liquibase
程序搭建
搭建了一个测试程序app
maven导入
maven导入
<!--liquibase自动化升级-->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
yaml文件配置
yaml文件配置
spring:
# 自动化升级
liquibase:
enabled: true
change-log: classpath:/db/master.xml
contexts: app
labels: app
tag: app
建立实例
在使用自动化升级之前,需要新建一个数据库实例
脚本编写
master.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="init_rceis" author="wt" runOnChange="true">
<sqlFile path="db/init/init_data.sql"/>
</changeSet>
</databaseChangeLog>
启动程序
启动程序,产生对应的脚本数据
本文小结
本文使用springboot整合liquibase来编写了一个简单的例子