【问题标题】:How would I configure FlyWay in IntegrationTest scope如何在 IntegrationTest 范围内配置 FlyWay
【发布时间】:2016-05-05 03:03:08
【问题描述】:

我正在尝试在 sbt 的子项目内的 IntegrationTest 配置范围内以不同方式配置 flyway:

// build.sbt

lazy val api = Project.project.in(file("api")).
  // ...
  settings(flywaySettings: _*).
  settings(
    // ...
    flywayUrl in IntegrationTest := "jdbc:postgresql://localhost:5432/mydb_test"
    flywayUser in IntegrationTest := "user"
    flywayPassword in IntegrationTest := "pw"
 )

但是当从 sbt 运行时,它仍在寻找默认范围内的值:

$ sbt

> api/it:flywayUrl
[info] jdbc:postgresql://localhost:5432/mydb_test

> api/it:flywayUser
[info] user

> api/it:flywayPassword
[info] pw

> api/it:flywayMigrate
// ...
[info] Flyway 3.2.1 by Boxfuse
[trace] Stack trace suppressed: run last api/*:flywayMigrate for the full output.
[error] (api/*:flywayMigrate) org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password!
[error] Total time: 3 s, completed 27-Jan-2016 1:33:08 PM

不知道我做错了什么......

【问题讨论】:

标签: scala playframework sbt flyway


【解决方案1】:

看来我需要使用inConfig

// build.sbt
lazy val api = Project.project.in(file("api")).

// copy the settings into the IntegrationTest Configuration
settings(inConfig(IntegrationTest)(flywaySettings): _*).
settings(
  // ...
  flywayUrl in IntegrationTest := "jdbc:postgresql://localhost:5432/mydb_test"
  flywayUser in IntegrationTest := "user"
  flywayPassword in IntegrationTest := "pw"
),

现在api/it:flywayMigrate 命令将从正确的范围内获取值。

【讨论】:

    猜你喜欢
    • 2017-08-29
    • 2021-12-02
    • 2015-03-26
    • 2019-10-23
    • 2010-10-21
    • 1970-01-01
    • 2017-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多