这里写目录标题
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文件首次启动后不要再修改此文件。