简体   繁体   English

Flyway'migrate'ant任务错误:“无法找到sql迁移的路径[…]”

[英]Flyway 'migrate' ant task error: “Unable to find path for sql migrations […]”

I can not specify the correct path to the directory with .sql files. 我无法使用.sql文件指定目录的正确路径。 I tried to set the "baseDir" attribute to different directories in different places (in classpath, of course) and set different classpath. 我试图将“ baseDir”属性设置为位于不同位置(当然是在类路径中)的不同目录,并设置了不同的类路径。 Build scripts always falls with message “ Unable to find path for sql migrations: [uri to directory with . 构建脚本始终带有消息“ 无法找到sql迁移的路径:[uri到目录。 sql files] ”. sql文件] ”。

It's not looking like issue 156 as was said in similar question , becourse if I delete the code in SqlMigrationResolver.java 它看起来不像在类似问题中所说的问题156 ,请问如果我删除SqlMigrationResolver.java中的代码,

if (StringUtils.hasText(baseDir) && !new ClassPathResource(baseDir + "/",
    classLoader).exists()) {
  LOG.warn("Unable to find path for sql migrations: " + baseDir);
  return migrations;
}

as was said in Comment #9 I still catch 正如评论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 falls at 飞路在

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

It can not execute getResources method. 它无法执行getResources方法。

It's not looking like bug, it's looking like I can not set right uri to directory with my SQL scripts =( 它看起来不像是bug,看起来像我无法使用SQL脚本=(

Please, help me to set this damn uri! 请帮我设置这个该死的uri!

My build.xml: 我的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>

Try changing flyway.classpath from a property to a path . 尝试将flyway.classpath属性更改为path

For your case this means changing this: 对于您的情况,这意味着更改此:

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

to this: 对此:

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

Instead of this: 代替这个:

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

Use: 采用:

<path id="flyway.classpath">  
      <pathelement location="c:\DeployTest"/>
</path>  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM