flywaydb

官网: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 =
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值