flyway - 未发现迁移。您的位置设置正确吗?

问题描述 投票:0回答:1

$树:

.
├── HELP.md
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
    ├── main
    │   ├── java
    │   │   └── com
    │   │       └── example
    │   │           └── j3
    │   │               ├── J3Application.java
    │   │               └── model
    │   │                   └── User.java
    │   └── resources
    │       ├── application.properties
    │       └── db
    │           └── migration
    │               └── V1__Create_user_table
    └── test
        └── java
            └── com
                └── example
                    └── j3
                        └── J3ApplicationTests.java

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>j3</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>j3</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>3.2.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>3.2.0</version>
        </dependency>

        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <version>8.0.33</version>
        </dependency>

        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-mysql</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.30</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

application.properties

spring.datasource.url=jdbc:mysql://localhost:3306/java_techie
spring.datasource.username=www_data
spring.datasource.password=pass

spring.jpa.properties.hibernate.format_sql=true
logging.level.org.hibernate.SQL=DEBUG
#spring.jpa.hibernate.ddl-auto=update

spring.flyway.baseline-on-migration=true

flyway 找不到迁移目录

...
Database: jdbc:mysql://localhost:3306/java_techie (MySQL 8.0)
2023-11-28T20:15:54.120+01:00  INFO 12018 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 0 migrations (execution time 00:00.021s)
2023-11-28T20:15:54.121+01:00  WARN 12018 --- [           main] o.f.core.internal.command.DbValidate     : No migrations found. Are your locations set up correctly?
2023-11-28T20:15:54.149+01:00  INFO 12018 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema `java_techie`: << Empty Schema >>
2023-11-28T20:15:54.155+01:00  INFO 12018 --- [           main] o.f.core.internal.command.DbMigrate      : Schema `java_techie` is up to date. No migration necessary.
spring-boot hibernate migration flyway
1个回答
0
投票

Flyway 将采用的命名模式:

V{VERSION_NUMBER}__{SCRIPT_DESCRIPTION}.sql

您的迁移脚本中似乎缺少文件扩展名。

© www.soinside.com 2019 - 2024. All rights reserved.