首页 > 解决方案 > Flyway 通配符在 Spring Boot 中不起作用

问题描述

我收到以下错误:


Flyway failed to initialize: none of the following migration scripts locations could be found:

    - classpath:db/*/migrations/

这是目录结构的样子:

文件夹结构

这就是我尝试过的:

# examples, obviously I tried these independently from each other
spring:
    flyway:
# these work:
        locations: "classpath:db"
        locations: "classpath:db/release_1.0/migrations/"

# these don't work: (I am getting the same error as shown above)
        locations: "classpath:db/**/migrations/"
        locations: "classpath:db/release*/migrations/"
        locations: "classpath:db/*/migrations/"

但它们应该根据6.4 版的这篇博文工作。(我没有看到他们已将其删除)

我正在使用spring-boot-starter-parent 2.4.1,所以它是Flyway 7.1.1

谁能向我解释如何在 Flyway 中使用通配符指定迁移文件夹,为什么它不起作用?

标签: spring-bootflyway

解决方案


随着 Flyway 的位置支持已经发展到支持通配符、云存储等,如本期所述,Spring Boot 准确检查位置的能力有所下降。因此,对位置检查的支持在 Spring Boot 2.5 中被弃用,并且在弃用期之后,它将被完全删除。同时,您可以通过设置spring.flyway.check-location将其关闭false


推荐阅读