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

2024-03-23

我有类似的问题this https://stackoverflow.com/questions/11226070/flyway-not-finding-the-migrations-in-a-jar-file但我已经迁移到版本 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 依赖于刚刚迁移的测试应用程序,并且迁移应用得很好......我不知道我能做什么。

编辑我已经启用了最好的日志记录,目前正在查找迁移

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)

扫描位置的默认名称是db/migration, not sql/migrations。如果你想使用sql/migrations相反,设置:

flyway.setLocations("sql/migrations");

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Flyway 仅在我的 jar 文件中找不到迁移 的相关文章

随机推荐