【springboot】【flyway】数据库版本控制

这里写目录标题

pom.xml

本项目 spring-boot版本2.3.0

注意根据后面实际路径配置<include>**/**/*.sql</include>

xml 复制代码
......
<dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-core</artifactId>
    <version>5.2.1</version>
</dependency>
......
<resource>
   <directory>src/main/resources</directory>
    <includes>
        <include>**/*.yml</include>
        <include>**/*.properties</include>
        <include>**/*.xml</include>
        <include>**/**/*.sql</include>
    </includes>
    <filtering>false</filtering>
</resource>
......

application.yml

locations: classpath:db/migration可改为自定义路径

yaml 复制代码
spring:
  flyway:
    enabled: true
    table: flyway_schema_history
    encoding: UTF-8
    baseline-on-migrate: true
    locations: classpath:db/migration
    sql-migration-prefix: V
    sql-migration-suffixes: .sql
    validate-on-migrate: true
    check-location: true
    clean-disabled: true

sql文件

相关sql文件放置在resources目录下,根据spring.flyway.locations新建文件夹db和子文件夹migration,创建相关VXXX__XXXX.sql

启动

如果数据库没有flyway_schema_history会自动创建,.sql文件首次启动后不要再修改此文件。

相关推荐
Pa2sw0rd丶3 分钟前
Fastjson 反序列化漏洞深度解析:从原理到实战防护
java·后端·安全
q***64976 分钟前
SpringSecurity踢出指定用户
android·前端·后端
Coding_Doggy9 分钟前
链盾shieldchiain | 团队功能、邀请成员、权限修改、移除成员、SpringSecurity、RBAC权限控制
java·开发语言·数据库
q***76669 分钟前
SpringSecurity 实现token 认证
android·前端·后端
凯子坚持 c10 分钟前
不用复杂配置!本地 Chat2DB 秒变远程可用,跨网操作数据库就这么简单
数据库
q***656911 分钟前
Windows环境下安装Redis并设置Redis开机自启
数据库·windows·redis
川白13 分钟前
为防在家摸鱼,用计网知识实践屏蔽B站!
后端
q***965818 分钟前
Windows版Redis本地后台启动
数据库·windows·redis
吃果冻不吐果冻皮19 分钟前
DeepSeek 视觉语言大模型技术演进(从DeepSeek VL/VL2到DeepSeek OCR)
后端
申阳19 分钟前
Day 15:01. 基于 Tauri 2.0 开发后台管理系统-Tauri 2.0 初探
前端·后端·程序员