10

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

Jeff D
  • 2,164
  • 2
  • 24
  • 39

6 Answers6

20

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

Axel Fontaine
  • 34,542
  • 16
  • 106
  • 137
  • 1
    what do you mean? can you explain better? I used netbeans 7.4 – Kick Buttowski Apr 06 '14 at 06:50
  • @Axel Fontaine like Jeff I have configured my pom.xml and I have my .sql scripts in the db/migration folder under resources.. on execution of the compile flyway:migrate I get com.googlecode.flyway.core.api.FlywayException: Unable to create schema ``: Incorrect database name '' what could be the issue? my sql file name is test.sql – Komal Goyal Apr 09 '14 at 12:38
  • What if I have my sql files in the current folder and not in db/migration? how to solve the problem? I do compile and then call migrate too. – user1164061 Aug 27 '14 at 00:10
5

In my case I had to explicitely set

flyway.locations=classpath:db/migration

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

ianaz
  • 2,490
  • 3
  • 28
  • 37
3

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

jhenya-d
  • 399
  • 7
  • 19
1

In my case IntelliJ Idea created a folder db.migration instead of two separate folders db and migration inside

Ilya Lisov
  • 138
  • 2
  • 11
0

It has to be compiled:

mvn compile flyway:migrate

You may use

<executions>
          <execution>
            <id>compile</id>
            <phase>compile</phase>
            <goals>
              <goal>migrate</goal>
            </goals>
          </execution>
          <execution>
            <id>clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>

in

<plugin>..</plugin> 

and then just mvn compile is needed for execution of migrate task

Cipous
  • 952
  • 7
  • 19
-1

Execute mvn command from directory where target dir is located.