Flyway只在我的jar文件中找不到迁移

时间:2013-07-04 15:39:56

标签: java migration flyway

我遇到与this类似的问题,但我已迁移到2.1.1版本,问题仍然存在。 我只是做那样的事情

 Flyway flyway = new Flyway();
    flyway.setLocations(MIGRATION_PACKAGES);
    flyway.setDataSource(getDatasource());
    flyway.setTable("schema_version");
    flyway.setSqlMigrationPrefix("v");
    flyway.migrate();

这没有问题导致我的IDE中的所有工作正常,但是当我在jar中打包时,没有找到我的迁移... 任何想法?

编辑:我已经测试过将包含迁移的jar放在依赖于刚刚迁移的测试应用程序并且迁移适用的情况下......我不知道我能做什么。

编辑我已启用FINEST日志记录,目前正在查找迁移

FINE: Scanning for resources at 'db/migration' (Prefix: 'v', Suffix: '.sql')
juil. 10, 2013 4:44:53 PM com.googlecode.flyway.core.util.scanner.ClassPathScanner findResourceNames
FINE: Unable to determine URL for classpath location: db/migration (ClassLoader: java.net.URLClassLoader@6458c2)
juil. 10, 2013 4:44:53 PM com.googlecode.flyway.core.util.scanner.ClassPathScanner scanForClasses
FINE: Scanning for classes at 'db/migration' (Implementing: 'com.googlecode.flyway.core.api.migration.jdbc.JdbcMigration')
juil. 10, 2013 4:44:53 PM com.googlecode.flyway.core.util.scanner.ClassPathScanner findResourceNames
FINE: Unable to determine URL for classpath location: db/migration (ClassLoader: java.net.URLClassLoader@6458c2)
juil. 10, 2013 4:44:53 PM com.googlecode.flyway.core.util.scanner.ClassPathScanner scanForResources
FINE: Scanning for resources at 'com/me/myapp/sql/migration' (Prefix: 'v', Suffix: '.sql')
juil. 10, 2013 4:44:53 PM com.googlecode.flyway.core.util.scanner.ClassPathScanner findResourceNames
FINE: Unable to determine URL for classpath location: com/me/myapp/sql/migration (ClassLoader: java.net.URLClassLoader@6458c2)
juil. 10, 2013 4:44:53 PM com.googlecode.flyway.core.util.scanner.ClassPathScanner scanForClasses
FINE: Scanning for classes at 'com/me/myapp/sql/migration' (Implementing: 'com.googlecode.flyway.core.api.migration.jdbc.JdbcMigration')
juil. 10, 2013 4:44:53 PM com.googlecode.flyway.core.util.scanner.ClassPathScanner findResourceNames
FINE: Unable to determine URL for classpath location: com/me/myapp/sql/migration (ClassLoader: java.net.URLClassLoader@6458c2)

1 个答案:

答案 0 :(得分:0)

扫描位置的默认名称为db/migration,而不是sql/migrations。如果您想使用sql/migrations,请设置:

flyway.setLocations("sql/migrations");