10

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?

newOne
  • 679
  • 2
  • 9
  • 27

4 Answers4

2

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>
Tinki
  • 1,486
  • 1
  • 21
  • 32
1

'classpath' means really classpath and you can not extend your classpath with a path.

When I see your classpath declaration than I think your migration will be packaged in a jar with the path 'com/some1/some2/some3/database/migration'

=> so your classpath configuration must be look like:

classpath:com/some1/some2/some3/database/migration

If you use SQL file based migration I have better experience with src/main/resources as base location.

Florian E.
  • 422
  • 4
  • 10
  • I try this and I wrote that isnt working. There is no need to declare key word "classpath", because when you put only path, without any keyword(classpath,filesystem) in default flyway treats its like classpath. Follow by documentation: "Unprefixed locations or locations starting with classpath". https://flywaydb.org/documentation/api/javadoc/org/flywaydb/core/Flyway.html#setLocations-java.lang.String...- – newOne May 22 '17 at 12:36
0

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"

Jayendran
  • 9,638
  • 8
  • 60
  • 103
0

Verify the classpath. In place of db/migration, I made db.migration