gpt4 book ai didi

java - Flyway 'migrate' ant任务错误: "Unable to find path for sql migrations [...]"

转载 作者:行者123 更新时间:2023-12-01 19:08:13 26 4
gpt4 key购买 nike

我无法指定包含 .sql 文件的目录的正确路径。我尝试将“baseDir”属性设置为不同位置(当然在类路径中)的不同目录,并设置不同的类路径。构建脚本总是会出现消息“无法找到 sql 迁移的路径:[uri 到带有 . sql 文件]”。

看起来不像issue 156正如 similar question 中所述,当然如果我删除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

飞行路线降落于

resources = new PathMatchingResourcePatternResolver(classLoader)
.getResources("classpath:" + searchRoot + searchPattern);

无法执行getResources方法。

这看起来不像 bug,看起来我无法使用 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>

最佳答案

尝试将flyway.classpath属性更改为路径

对于您的情况,这意味着更改此:

<property name="flyway.classpath" value="c:\DeployTest"/>

对此:

<path id="flyway.classpath">
<fileset dir="c:\DeployTest"/>
</path>

关于java - Flyway 'migrate' ant任务错误: "Unable to find path for sql migrations [...]",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9259939/

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