【问题标题】:Unable to disable flyway via spring.flyway.enabled无法通过 spring.flyway.enabled 禁用 flyway
【发布时间】:2020-07-07 00:31:51
【问题描述】:

我使用 flyway 作为我的本地配置文件来填充数据库以进行集成测试。

application.yml:

spring:
  (...)
  flyway.enabled: false

application-local.yml:

spring:
  (...)
  flyway:
    enabled: true
    license-key: (...)
    locations: classpath:mssql/migrations

预期:

应用程序在启动过程中不会尝试使用配置文件 dev 自动配置 flyway

实际:

The following profiles are active: dev
(...)
org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext
    Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException:
    (...)
    Factory method 'flyway' threw exception; nested exception is org.springframework.boot.autoconfigure.flyway.FlywayMigrationScriptMissingException: 
    Cannot find migration scripts in: [classpath:db/migration] (please add migration scripts or check your Flyway configuration)

版本:

flyway 核心 6.3.1 弹簧靴 2.2.5

【问题讨论】:

  • 请展示您如何配置弹簧配置文件

标签: spring spring-boot flyway


【解决方案1】:

您指定了application-local.yml,这意味着您指定了local 配置文件,但您使用dev 配置文件运行应用程序。有两个潜在问题:

  1. 您使用错误的配置文件运行应用程序:应该是 local 而不是 dev
  2. 或者您没有将local 个人资料添加到dev https://docs.spring.io/spring-boot/docs/1.1.6.RELEASE/reference/html/boot-features-profiles.html

【讨论】:

    猜你喜欢
    • 2016-05-22
    • 1970-01-01
    • 2017-11-24
    • 1970-01-01
    • 2015-02-18
    • 1970-01-01
    • 2018-10-06
    • 2021-05-08
    相关资源
    最近更新 更多