您的位置:首页 > 编程语言 > Java开发

197. Spring Boot 2.0数据库迁移:Liquibase

2018-07-21 15:49 531 查看

 

【视频&交流平台】

à SpringBoot视频http://t.cn/R3QepWG

à SpringCloud视频http://t.cn/R3QeRZc

à Spring Boot源码:https://gitee.com/happyangellxq520/spring-boot

à Spring Boot交流平台:http://412887952-qq-com.iteye.comhttps://blog.csdn.net/blog/2321532

à Spring Boot Shiro视频http://t.cn/R3QDMbh

à Spring Boot 2.0 之Spring Data 和JPAhttp://t.cn/R1pSojf

 

历史相关章节:

193. Spring Boot 数据库迁移:概述

194. Spring Boot 数据库迁移:Flyway

 

195. Spring Boot 2.0数据库迁移:Flyway

 

196. Spring Boot 数据库迁移:Liquibase

 

 

说明:

(1)Spring Boot 版本:2.0.0.RELEASE

(2)Liquibase版本:3.5.5

 

前言:

       在上一节中spring boot使用了1.5.12.RELEASE,这里我们要看看2.0.0.RELEASE的一个使用情况。大体的思路和上一篇是使用的,这里我们在上一篇文章的基础上进行调整。

 

一、版本说明

       这里的Spring Boot版本使用的是2.0.0.RELEASE,Liquibase这里还是3.5.5的版本的。

二、准备工作

       在上一篇的基础上,我们首先要修改下配置文件application.properties,因为在2.0.0配置路径的配置项修改了,如下配置:

spring.liquibase.change-log= classpath:/db/changelog/db.changelog-master.sql

 

 当1.5.12版本是如下配置:

liquibase.change-log= classpath:/db/changelog/db.changelog-master.sql

       这里由于Liquibase的版本还是3.5.5版本的,所以不需要数据库的表结构信息就可以测试了。

三、测试

       到这里就可以运行测试了,顺利的话, 一切就会如之前一样的效果了。

四、配置说明

       对于2.x的版本,Liquibase的配置加上了spring的前缀,如下配置:

# LIQUIBASE (LiquibaseProperties)
spring.liquibase.change-log=classpath:/db/changelog/db.changelog-master.yaml # Change log configuration path.
spring.liquibase.check-change-log-location=true # Whether to check that the change log location exists.
spring.liquibase.contexts= # Comma-separated list of runtime contexts to use.
spring.liquibase.default-schema= # Default database schema.
spring.liquibase.drop-first=false # Whether to first drop the database schema.
spring.liquibase.enabled=true # Whether to enable Liquibase support.
spring.liquibase.labels= # Comma-separated list of runtime labels to use.
spring.liquibase.parameters.*= # Change log parameters.
spring.liquibase.password= # Login password of the database to migrate.
spring.liquibase.rollback-file= # File to which rollback SQL is written when an update is performed.
spring.liquibase.url= # JDBC URL of the database to migrate. If not set, the primary configured data source is used.
spring.liquibase.user= # Login user of the database to migrate.

Spring Boot 1.x的版本的配置如下:

# LIQUIBASE (LiquibaseProperties)
liquibase.change-log=classpath:/db/changelog/db.changelog-master.yaml # Change log configuration path.
liquibase.check-change-log-location=true # Check the change log location exists.
liquibase.contexts= # Comma-separated list of runtime contexts to use.
liquibase.default-schema= # Default database schema.
liquibase.drop-first=false # Drop the database schema first.
liquibase.enabled=true # Enable liquibase support.
liquibase.labels= # Comma-separated list of runtime labels to use.
liquibase.parameters.*= # Change log parameters.
liquibase.password= # Login password of the database to migrate.
liquibase.rollback-file= # File to which rollback SQL will be written when an update is performed.
liquibase.url= # JDBC url of the database to migrate. If not set, the primary configured data source is used.
liquibase.user= # Login user of the database to migrate.

 

 

「SpringCloud视频」最近更新:

 

24. 覆写Feign的默认配置Configuration之Contract
25. Spring Cloud中关于Feign的常见问题总结
26. 解决Spring Cloud中FeignRibbon第一次请求失败的方法
27. Feign添加 fallbackFactory 属性来触发请求进行容灾降级
28. 断路器Hystrix总结
29. Health Indicator(健康指标) 和metrics stream(指标流)
30. 断路器监控(Hystrix Dashboard)
31. 断路器聚合监控(turbine)

 SpringCloud视频http://t.cn/R3QeRZc

 

 

微信公众号「SpringBoot」最近更新:

 

Java8新特性:接口的默认方法
208. Spring Boot Swagger2:排序 – 漂游记
207. Spring Boot Swagger2:极简方式
我读的书很多,但都没有你好看【一禅录】
206. Spring Boot 2.0 Swagger2:使用
205. Spring Boot 2.0 Swagger2:初识Swagger
当要离开的时候,我却动情了
205. jetcache:你需要知道的小技巧
204. jetcache:在Spring Boot中怎么玩?
遇见阿里,遇见自己
203. 阿里jetcache
202. 阿里Pandora Boot
微信公众号赞赏功能升级了,真的假的?
《喜剧之王》「我养你啊」之人生选择
201. Spring Boot JNDI:Spring Boot中怎么玩JNDI
510阿里日,马老师献上最走心、最科技范儿证婚词~
200. Spring Boot JNDI:在Tomcat中怎么玩JNDI?
199. Spring Boot JNDI:这是虾米?
Spring Boot 数据库迁移系列
Spring Boot葵花宝典:初露锋芒:MyBatis insert异常 Parameter 'name' not found
198. Spring Boot Flyway工作原理

 搜索「springboot」或者扫描以下二维码即可关注:

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: