Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flyway not finding my sql migrations in db/migration

Tags:

flyway

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>

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

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

like image 415
Jeff D Avatar asked Apr 15 '13 16:04

Jeff D


3 Answers

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

like image 101
Axel Fontaine Avatar answered Nov 14 '22 06:11

Axel Fontaine


in my case this error was caused as package with name db.migration was created instead of db -> migration

like image 24
jhenya-d Avatar answered Nov 14 '22 06:11

jhenya-d


In my case I had to explicitely set

flyway.locations=classpath:db/migration

in my application.properties (Spring Boot) for it to work.

like image 39
ianaz Avatar answered Nov 14 '22 07:11

ianaz