1.添加Maven依赖
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>5.0.3</version>
</dependency>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>5.0.3</version>
<configuration>
<configFile>src/main/resources/flyway.properties</configFile>
</configuration>
</plugin>
2.flyway.properties配置
flyway.url=jdbc:mysql://localhost:3306
flyway.schemas=test
flyway.user=root
flyway.password=root
3.创建SQL脚本
脚本默认在resources/db/migration目录下
格式
Vx_x__tableName_operatorName.sql
4.使用
mvn flyway:info 查看各脚本执行情况
mvn flyway:migrate 执行脚本
源码 https://gitee.com/jsjack_wang/springboot-demo dev-flyway分支