Spring Data Jpa 如何修复“没有找到迁移,您的位置设置正确吗?”在MySQL的Flyway迁移?

kpbpu008  于 9个月前  发布在  Spring
关注(0)|答案(1)|浏览(119)

我正在使用Sping Boot 3创建一个Java项目,使用:

  1. Flyway migration with a file:application.properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.datasource.url=jdbc:mysql://localhost:3306/vollmed_api
    spring.datasource.username=admin
    spring.datasource.password=12345

字符串

  1. resources/db.migration/V1__create-table-doctor.sql
create table doctors(
    id bigint not null auto_increment,
    name varchar(100) not null,
    email varchar(100) not null unique,
    crm varchar(6) not null unique,
    specialty varchar(100) not null,
    street varchar(100) not null,
    neighborhood varchar(100) not null,
    zipcode varchar(9) not null,
    complement varchar(100),
    number varchar(20),
    state char(2) not null,
    city varchar(100) not null,

    primary key(id)

 );


1.当我运行de API.application时,终端总是显示消息:enter image description here
1.我也尝试创建另一个文件来更改表“resources/db.migration/V2__alter-table-doctor.sql”,但问题仍然存在,在终端显示相同的消息。
观察结果:

  • 我试着把application.properties从:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.datasource.url=jdbc:mysql://localhost:3306/vollmed_api
    spring.datasource.username=admin
    spring.datasource.password=12345


收件人:

spring.datasource.url=jdbc:mysql://localhost:3306/vollmed_api
    spring.datasource.username=admin
    spring.datasource.password=12345


但问题依然存在。

  • 我已经尝试打开我的数据库,删除并手动创建数据库,它的工作正常!

拜托,你能帮帮我吗?
另一个问题,我意识到我没有在我的IntelliJ终端上运行MySQL:enter image description here当我安装一个扩展DB浏览器时,我只是得到了“一般般”。
使用FLYWAY Migration from Sping Boot 3(IntelliJ)在MySQL中创建和更改表。

falq053o

falq053o1#

我已经更改了application.properties并包含了配置:“spring.flyway.locations=classpath:db/migration”。但我没有更改文件夹“db.migration”。之后,我删除了我的数据库,重新创建了它,并运行了API。它现在可以工作了!

相关问题