springboot flyway 整合(不生效原因)

前言:

整合springboot 和 flyway  其实网上有很多,但是我在用时发现一个问题,有版本的限制,如果大家发现flyway 不生效,可以使用下我这种指定jar版本的例子。

原因:个人发现可能版本出现了问题

代码下载链接:https://download.csdn.net/download/wcy18818429914/19777008

1、POM 文件(更新下pom 就可以了)

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.1.8.RELEASE</version>
        </dependency>

        <!--flyway-->
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
            <version>5.2.4</version>
        </dependency>

        <!--mysql连接依赖-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.46</version>
        </dependency>
        <!-- mybatis -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.3</version>
        </dependency>
    </dependencies>

这里是顺便整合下springboot 和 flyway 的功能

V0.1.2__init_data.sql

drop table if exists id_name;

/*==============================================================*/
/* Table: sh_virtual_device                                     */
/*==============================================================*/
create table id_name
(
   id                   varchar(36) not null comment '主键',
   name              varchar(36) comment '名称',
   primary key (id)
);

application.yml

server:
  port: 8010
spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/flyway?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true
    username: root
    password: root
    sql-script-encoding: UTF-8 #指定插入数据库数据的编码方式

  flyway:
    baseline-on-migrate: true

运行DemoApplication程序

结果如下:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值