Flyway仅在我的jar文件中找不到偏头痛 [英] Flyway not finding migraions only in my jar file

查看:140
本文介绍了Flyway仅在我的jar文件中找不到偏头痛的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与类似的问题但我已经迁移到2.1.1版,问题仍然存在. 我只是做类似的事情

I have a similar problem to this but I've migrate to version 2.1.1 and the problem are still here. I just do something like that

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

这没有问题,可以在我的IDE中正常工作,但是当我将其打包在jar中时,找不到我的迁移... 有什么想法吗?

There is no problem with that cause all work fine in my IDE, but when I package in jar, that not found my migrations ... any ideas ?

我已经进行过测试,将包含迁移的jar依赖于刚刚迁移的测试应用程序,并且迁移可以很好地应用...我不知道我能做什么.

I've already test to put my jar who contain the migration in dependency of a test app who just migrate and the migrations are apply fine ... I don't know what i can do.

编辑我已启用FINEST日志记录,此刻已找到迁移

Edit I've enabled the FINEST logging and at the moment to find migration

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,请设置:

The default name of the scanned location is db/migration, not sql/migrations. If you want to use sql/migrations instead, set:

flyway.setLocations("sql/migrations");

这篇关于Flyway仅在我的jar文件中找不到偏头痛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆