无法通过 spring.flyway.enabled 禁用 Flyway

问题描述 投票:0回答:2

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

application.yml

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

application-local.yml

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

预期:

应用程序在启动过程中不会尝试使用配置文件自动配置飞行路线

dev

实际:

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
2个回答
0
投票

您指定了

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

0
投票

您的配置文件有错误:

应该是这样的:

春天: (...) 飞行路线: 启用:假

© www.soinside.com 2019 - 2024. All rights reserved.