简体   繁体   中英

FlyWayDB - Unable to resolve location classpath

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?

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

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 path Project -> Properties -> SourceTab -> AddFolder it takes the scripts to classpath with the desired folder name and keeps that name into your JavaClass

"classpath:foldername"

For meu the resources at pom.xl answer given by @Tinki was what resolved my case

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM