FlyWayDB - Unable to resolve location classpath

Viewed 15778

i have problem to setting location with the classpath in FLyway, when I use with the filesystem its working properly.

Example:

This working: this.setLocations("filesystem:C:\\Projects\\ProjectName\\src\\main\\java\\com\\some1\\some2\\some3\\database\\migration");

This NOT working(I try delimiters: "\", ".", "/"): this.setLocations("classpath:ProjectName/src/main/java/com/some1/some2/some3/database/migration");

When not working, its throwing error:

[WARNING] [] [org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner] [tid: _ThreadID=19 _ThreadName=RunLevelControllerThread-xx] [timeMillis: 1495044249009] [levelValue: 900] [[ Unable to resolve location classpath: ProjectName/src/main/java/com/some1/some2/some3/database/migration]]

I try some delimiters as above, without key word "classpath", and always when I want to use classpath its throwing "Unable to resolve location ...".

I use flyway ver 4.1.2 and by JavaAPI(https://flywaydb.org/getstarted/firststeps/api)

edit./ When I change location of migrating sql files and name of directory on default for Flyway, and not setting location, its working fine. So, conclusion is that I wrong wrote the classpath, but what i do wrong?

Default configuration: 1. main/resources/db/migration < default folder for sql files to migrate 2. not setting location

Some suggestion?

3 Answers

I struggled with the same problem for a couple of days. What finally helped me was to modify pom.xml, so that<build> node lists all locations with property files:

<project...>
  ...
  <build>
     <resources>
        ...
        <resource>
           <directory>src/main/resources</directory>
           <includes>
             <include>*.*</include>
             <include>sql/migration/*</include>
           </includes>
        </resource>
     </resources>
  </build>
</project>

Instead of creation complete package for DB migrate scripts, suggested to create a folder at java build pathProject -> Properties -> SourceTab -> AddFolder it takes the scripts to classpath with the desired folder name and keeps that name into your JavaClass

"classpath:foldername"

Related