【问题标题】:Flyway: Unable to determine URL for classpath locationFlyway:无法确定类路径位置的 URL
【发布时间】:2023-03-22 09:49:01
【问题描述】:

我正在使用 flyway 迁移我的 SQL 脚本。我已将 flyway 配置文件配置为指向保存迁移 .sql 脚本的 /tmp/sql 目录。

现在,当我运行 flyway 时,它给了我以下错误:

ERROR: Unable to scan for SQL migrations in location: classpath:tmp/sql"/>
ERROR: Caused by: org.flywaydb.core.api.FlywayException: Unable to determine URL for classpath location: tmp/sql"/> (ClassLoader: java.net.URLClassLoader@2da679b7)
ERROR: Occured in org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner.getLocationUrlsForPath() at line 192

现在,如果我让 flyway.locations 属性不变并将我的 sql 迁移脚本保留在文件系统中:Flyway-INSTALL-DIR/sql 它工作正常。

谁能告诉我可能是什么问题?

我想将 sql 迁移脚本保存在单独的位置并尝试从那里迁移。

谢谢, 马尼什·乔希

【问题讨论】:

    标签: sql flyway


    【解决方案1】:

    确保 flyway.locations 设置为 filesystem:/tmp/sql

    【讨论】:

    • 嗨 Axel,即使这样我也收到以下错误:错误:无法扫描位置中的 SQL 迁移:文件系统:/tmp/sql"/> 错误:原因:org.flywaydb.core .api.FlywayException:无效的文件系统路径:/tmp/sql"/> 错误:发生在 org.flywaydb.core.internal.util.scanner.filesystem.FileSystemScanner.scanForResources() 的第 48 行
    • 路径/tmp/sql确实存在,内容如下:[root@NewVoE6-osm01 flyway-3.0]# ls -ltr /tmp/sql total 20 -rw-r--r- - 1 根根 76 12 月 8 日 17:49 V4__manish.sql -rw-r--r-- 1 根根 79 12 月 8 日 17:49 V3__Create_employee_table.sql -rw-r--r-- 1 根根 270 17 年 12 月 8 日:49 V2__Add_People.sql -rw-r--r-- 1 根 79 12 月 8 日 17:49 V1__Create_person_table.sql -rw-r--r-- 1 根 0 12 月 8 日 17:49 put-your-sql- migrations-here.txt -rw-r--r-- 1 root root 12 Dec 8 17:55 V5__hello.sql
    • 使用 3.1 重试并使用 -X 添加一些调试输出以查看问题所在
    【解决方案2】:

    至少添加一个文件到 src/main/resources/db/migration 就可以了。如果目录为空,Maven 有时不会将目录复制到目标。

    【讨论】:

      【解决方案3】:

      如果上述方法没有帮助,您也可以试试这些吗?

      flyway.locations=classpath:db/migration
      

      spring.flyway.locations=classpath:db/migration
      

      并确保您使用的路径确实存在:即我在使用 db/migrations 时遇到问题,但真正的路径是 db/migration。很傻,但在此处添加它可能会节省其他人的时间浪费。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-10-17
        • 2018-03-18
        • 1970-01-01
        • 1970-01-01
        • 2017-08-04
        • 1970-01-01
        • 2012-02-07
        • 2020-09-07
        相关资源
        最近更新 更多