migration中找不到我的SQL迁移

migration中找不到我的SQL迁移

本文介绍了Flyway在db/migration中找不到我的SQL迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:[错误] com.googlecode.flyway.core.api.FlywayException:无法确定类路径位置的URL:db/migration(ClassLoader:ClassRealm [plugin> com.googlecode.flyway:flyway-maven-plugin:2.1.1,父级:sun.misc.Launcher$AppClassLoader@43be2d65])

The error:[ERROR] com.googlecode.flyway.core.api.FlywayException: Unable to determine URL for classpath location: db/migration (ClassLoader: ClassRealm[plugin>com.googlecode.flyway:flyway-maven-plugin:2.1.1, parent: sun.misc.Launcher$AppClassLoader@43be2d65])

我遵循了快速入门,所以我实际上还没有做任何复杂的事情.

I followed the quickstart, so I'm not really doing anything complex yet.

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.cpt.migrations</groupId>
  <artifactId>cpt_migrations</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>cpt_migrations</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.24</version>
    </dependency>
  </dependencies>
  <build>
      <plugins>
          <plugin>
              <groupId>com.googlecode.flyway</groupId>
              <artifactId>flyway-maven-plugin</artifactId>
              <version>2.1.1</version>
              <configuration>
                  <user>root</user>
                  <password></password>
                  <driver>com.mysql.jdbc.Driver</driver>
                  <url>jdbc:mysql://localhost:3306/cpt</url>
              </configuration>
          </plugin>
      </plugins>
  </build>
</project>

我的文件夹结构是规定的PROJECT_ROOT/src/main/resources/db/migration/V1__Base_version.sql:

And my folder structure is the prescribed PROJECT_ROOT/src/main/resources/db/migration/V1__Base_version.sql:

从PROJECT_ROOT执行以下命令时出现错误:mvn flyway:迁移

I get the error when, from the PROJECT_ROOT, I execute:mvn flyway:migrate

推荐答案

别忘了先调用compile,以确保将资源复制过来.

Don't forget to call compile first, to make sure the resources are copied over.

这篇关于Flyway在db/migration中找不到我的SQL迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:39