spring boot集成liquibase,

liquibase是一个升级脚本工具,且可以进行前置条件的约束

spring boot集成liquibase

步骤1、添加依赖


        
            org.liquibase
            liquibase-core
        

        
            mysql
            mysql-connector-java
        
        
            org.springframework.boot
            spring-boot-starter-jdbc
        

步骤2:配置application.properties

#### datasource  不配置这个?serverTimezone=UTC 会报错如下错误
# The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone
server.port=9090
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.max-idle=10
spring.datasource.max-wait=10000
spring.datasource.min-idle=5
spring.datasource.initial-size=5
# LIQUIBASE (LiquibaseProperties)
spring.liquibase.check-change-log-location=true
spring.liquibase.drop-first=false
spring.liquibase.enabled=true
spring.liquibase.change-log=classpath:/liqubase/changeLog.xml

步骤3:在liqubase/changeLog.xml




    runOnChange="false">
 
    
        select count(*) from user_name where user_name = 22;
    

新增脚本       
           INSERT INTO `user_name` ( `user_name`, `phone`, `address`) VALUES ( '22', '33', '22');
       
 
 DELETE from  user_name where user_name = 22;
 
    

 

你可能感兴趣的:(spring,boot,liquibase)