gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-11-01 03:53:23 25 4
gpt4 key购买 nike

我有一个与 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)

最佳答案

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

flyway.setLocations("sql/migrations");

关于java - Flyway 仅在我的 jar 文件中找不到迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17474096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com