FlywayException: Unable to scan for SQL migrations in location: classpath:db/migration

illegalstateexception cannot find migrations location in classpath db migration
flyway schema has version but no migration could be resolved in the configured locations
java lang illegalstateexception cannot find migrations location
flyway force migrate
flyway warning skipping filesystem location
flyway validate on migrate
flyway skip migration
flyway not finding migrations

I'm trying to start using flyway with maven integration but can't make it work.

I'm following the documentation seems to be very simple so no strange things seem to be done.

My pom.xml is the following:

<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>

I have the directory resources/db/migration/ without any migration yet.

When I issuing flyway:info on cygwin or cmd I got an flyway error:

$ 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] ------------------------------------------------------------------------

Can give me a hand on this?

Thans a lot.

This also happens if the compile goal is not executed before calling flyway:migrate. Actually this IS included in the quick start manual. It says:

mvn compile flyway:migrate

However if you miss that detail and start to just call mvn flyway:migrate, the SQL file will not get copied into the target directory (actually the target directory will not even exist) and you get this cryptic error.

FlywayException: Unable to determine URL for classpath location , FlywayException: Unable to scan for SQL migrations in location: classpath:db/ migration: Unable to determine URL for classpath location:�

Well, just for you to know.

I found the problem, it happens when we setup flyway in our environment but we don't have any migration to be executed.

It shouldn't display a classpath error but fortunately it's working.

By the way, another problem I found is that after executing init if we check with info nothing is displayed. And if we add a new migration with V1 then info won't show it unless we change it to V1_1

Hope to help

classpath scanner does not find db.migration package or resources , classpath scanner does not find db.migration package or resources #1261 ClassPathScanner] Unable to resolve location classpath:db/migration DEBUG DbMigrate] Successfully applied 2 migrations to schema "public" (execution Flyway finds only the migration sql scripts in the filesystem or in the�

I had a similar problem and it was because when I created the migration directory I gave it the name db.migration directly.

By creating the directory db and then inside it the migration directory it worked.

[THORN-1269] Flyaway fraction does not detect migration scripts in , Unable to scan for SQL migrations in location: classpath:db/migration. Question. I am using flyway to do the SQL migration , the sql migration worked for me�

I ran into the same problem. In my case, I had my migration script in the wrong directory that had caused the issue. I moved the script V1__Create_person_table.sql to the right directory at resources/db/migration/ and it worked!!

Command-line: repair, Flyway fraction will not detect any migration scripts nor find classpath db/ migration when 2017-04-12 15:43:09,132 WARN [org.flywaydb.core.internal. util.scanner.classpath. Thread Pool – 10) Unable to resolve location classpath: db/migration Pool – 10) Successfully validated 0 migrations (execution time 00: 00.003s)

I faced the same issue. But when i obeserved the logs keenly i found flywaydb is looking in db/migration folder for the script but my script is in db/migrate. so, after correcting the path from db/migrate to db/migration it works!!.

Command-line: migrate, Remove any failed migrations on databases without DDL transactions This schema will be automatically set as the default one during the migration. Comma-separated list of locations to scan recursively for migrations. on the classpath and may contain both SQL and Java-based migrations. (e.g. db/ release1.

Using Flyway, After each failed attempt, Flyway will wait 1 second before attempting to Unprefixed locations or locations starting with classpath: point to a package on the Undo SQL migrations are responsible for undoing the effects of the versioned flyway migrate Flyway 6.5.3 by Redgate Database: jdbc:h2:file: flyway.db (H2 1.3)�

Issue 239 in flyway: Flyway 1.6 classpath scanner does not find files , add your migrations to the src/main/resources/db/migration folder as you usually do with Flyway Comma-separated list of locations to scan recursively for migrations. on the classpath and may contain both SQL and Java-based migrations. After each failed attempt, Flyway will wait 1 second before attempting to�

flyway 无法识别sql,Unable to scan for SQL migrations in location。, <bean id="flywayMigration" class="com.googlecode.flyway.core.Flyway" init- method="migrate"> This will fail to find any migrations under '<classpath>/ migrations/'. However flyway.baseDir=sql/applicationname (where application name is a subfolder of sql) (classpath location: db/migration) [ DEBUG]�

Comments
  • Check my this answer hopefully it becomes helpful, stackoverflow.com/a/59478383/9437031
  • This was probably due to maven not creating the output directory if the input directory is empty. P.S.: You probably don't need init. That's for existing databases only. For new ones migrate is enough.