gpt4 book ai didi

java - 飞路异常 : Unable to scan for SQL migrations in location: classpath:db/migration

转载 作者:太空狗 更新时间:2023-10-29 23:02:11 25 4
gpt4 key购买 nike

我正在尝试开始将 flyway 与 Maven 集成一起使用,但无法正常工作。

我遵循的文档似乎非常简单,所以似乎没有做任何奇怪的事情。

我的 pom.xml 如下:

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>


<build>
<plugins>
<!-- Flyway plugin configuration -->
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>3.0</version>
<configuration>
<url>jdbc:mysql://localhost:3306/test</url>
<user>test_fede</user>
<password>test_fede</password>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>13.0.1</version>
</dependency>

<!-- DB dependencies -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

我的目录 resources/db/migration/ 还没有任何迁移。

当我在 cygwin 或 cmd 上发布 flyway:info 时,我遇到了 flyway 错误:

$ mvn compile flyway:info
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - com.test:test:jar:0.0.1-SNAPSHOT
[INFO] task-segment: [compile, flyway:info]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [flyway:info {execution: default-cli}]
[INFO] Database: jdbc:mysql://localhost:3306/test (MySQL 5.5)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] org.flywaydb.core.api.FlywayException: Unable to scan for SQL migrations in location: classpath:db/migration

Embedded error: Unable to determine URL for classpath location: db/migration (ClassLoader: org.codehaus.classworlds.RealmClassLoader@5bcdbf6)
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue May 06 11:06:15 CST 2014
[INFO] Final Memory: 17M/223M
[INFO] ------------------------------------------------------------------------

可以帮我解决这个问题吗?

非常感谢。

最佳答案

如果在调用 flyway:migrate 之前未执行编译目标,也会发生这种情况。实际上这包含在快速入门手册中。它说:

mvn compile flyway:migrate

但是如果你错过了这个细节并开始调用 mvn flyway:migrate,SQL 文件将不会被复制到目标目录中(实际上目标目录甚至不存在)你会得到这个神秘的错误。

关于java - 飞路异常 : Unable to scan for SQL migrations in location: classpath:db/migration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23501244/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com