Fed*_*zza 15 java database maven flyway
我正在尝试使用maven集成的flyway,但无法使其工作.
我跟着文档似乎很简单所以似乎没有什么奇怪的事情要做.
我的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>
Run Code Online (Sandbox Code Playgroud)
我有目录resources/db/migration /,还没有任何迁移.
当我发出flyway:关于cygwin或cmd的信息时,我遇到了一个飞路错误:
$ 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] ------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
可以帮我个忙吗?
吃了很多.
yan*_*kee 15
如果在调用flyway:migrate之前未执行编译目标,也会发生这种情况.实际上,这包括在快速入门手册中.它说:
mvn 编译 flyway:迁移
但是,如果你错过了那个细节并开始只是调用mvn flyway:migrate,那么SQL文件将不会被复制到目标目录中(实际上目标目录甚至不存在),你会得到这个神秘的错误.
Fed*_*zza 10
好吧,只为你知道.
我发现了问题,它发生在我们在环境中设置flyway但我们没有任何迁移要执行.
它不应该显示类路径错误,但幸运的是它正在工作.
顺便说一句,我发现的另一个问题是,在执行init后,如果我们检查信息,则不显示任何内容.如果我们使用V1添加新的迁移,那么除非我们将其更改为V1_1,否则信息将不会显示
希望能有所帮助
小智 6
我遇到了同样的问题。就我而言,我的迁移脚本位于导致问题的错误目录中。我将脚本 V1__Create_person_table.sql 移到了 resources/db/migration/ 中的正确目录,并且成功了!!