【发布时间】:2012-03-04 19:41:37
【问题描述】:
我无法指定带有 .sql 文件的目录的正确路径。我试图将“baseDir”属性设置为不同位置的不同目录(当然是在类路径中)并设置不同的类路径。构建脚本总是带有消息“无法找到 sql 迁移的路径:[uri to directory with . sql 文件]”。
它不像similar question 中所说的issue 156,当然如果我删除SqlMigrationResolver.java 中的代码
if (StringUtils.hasText(baseDir) && !new ClassPathResource(baseDir + "/",
classLoader).exists()) {
LOG.warn("Unable to find path for sql migrations: " + baseDir);
return migrations;
}
正如Comment #9 中所说的,我仍然抓到了
deployDB:
[flyway:migrate] com.googlecode.flyway.core.exception.FlywayException: Error loading sql migration files
[flyway:migrate] Caused by java.io.FileNotFoundException: class path resource [db/migration/] cannot be resolved to URL because it does not exist
BUILD FAILED
c:\DeployTest\build.xml:208: Flyway Error: com.googlecode.flyway.core.exception.FlywayException: Error loading sql migration files
Flyway 落在
resources = new PathMatchingResourcePatternResolver(classLoader)
.getResources("classpath:" + searchRoot + searchPattern);
无法执行getResources方法。
看起来不像是错误,看起来我无法使用我的 SQL 脚本为目录设置正确的 uri =(
请帮我设置这个该死的 uri!
我的 build.xml:
<target name="init-flyway">
<taskdef uri="antlib:com.googlecode.flyway.ant"
resource="com/googlecode/flyway/ant/antlib.xml"
/>
<property name="flyway.driver" value="${dbDriver}"/>
<property name="flyway.url" value="${dbUrl}"/>
<property name="flyway.user" value="${dbScheme}"/>
<property name="flyway.password" value="${dbPass}"/>
<property name="flyway.baseDir" value="\db\migration"/>
<property name="flyway.classpath" value="c:\DeployTest"/>
</target>
<target name="deployDB" depends="init-flyway">
<flyway:migrate/>
</target>
【问题讨论】:
-
为了确定起见,请尝试将您的 '\' 替换为 '/'。
-
@nico_ekito 是的,我已经尝试过这样做。它没有给出任何结果。
-
你试过“/db/migration”(从错误信息看,第一个“/”不见了)?
-
@nico_ekito 我了解谁,没关系,我们使用什么样的分隔符。我试过 "/db/migration"、"\db\migration"、"db/migration" 和 "db\migration "。错误消息始终是 [db/migration/]。
-
“\db\migration”文件夹是否是您资源的一部分(即在类路径中)?