官网:flywaydb.org
属性设置方式:迁移方式一:(提前生成好classpath:的文件,再通过导入依赖配置自动装配FlywayProperties,不适合生产环境)
设置脚本迁移目录和脚本文件:
启动服务,生成classpath:对于脚本文件
导入依赖:
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
重启服务,打印迁移成功的日志:
2020-02-21 17:47:06.329 [ INFO] [main] org.flywaydb.core.internal.license.VersionPrinter:49 : Flyway Community Edition 6.2.3 by Redgate
2020-02-21 17:47:07.148 [ INFO] [main] org.flywaydb.core.internal.database.DatabaseFactory:49 : Database: jdbc:mysql://127.0.0.1:3306/springtest (MySQL 5.7)
2020-02-21 17:47:07.243 [ INFO] [main] org.flywaydb.core.internal.command.DbValidate:49 : Successfully validated 1 migration (execution time 00:00.037s)
2020-02-21 17:47:07.284 [ INFO] [main] org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory:49 : Creating Schema History table `springtest`.`flyway_schema_history` ...
2020-02-21 17:47:07.369 [ INFO] [main] org.flywaydb.core.internal.command.DbMigrate:49 : Current version of schema `springtest`: << Empty Schema >>
2020-02-21 17:47:07.379 [ INFO] [main] org.flywaydb.core.internal.command.DbMigrate:49 : Migrating schema `springtest` to version 1 - Create table
2020-02-21 17:47:07.433 [ INFO] [main] org.flywaydb.core.internal.command.DbMigrate:49 : Successfully applied 1 migration to schema `springtest` (execution time 00:00.083s)
方式二:(通过@Bean的方式自定义FlywayProperties,指定sql脚本查找路径,一次启动就可以生成数据库映射)
@Bean方式:
@ConditionalOnWebApplication
@ConditionalOnProperty(prefix = "event", name =