多模块 Scala Play 2.3 conf 位置
Multi module Scala Play 2.3 conf location
我的任务是将旧的 ant 构建脚本重写为 SBT。碰巧,我们的套件由 3 个模块组成:
- Play 2.3 前端网络服务器;
- 从各种其他系统检索数据的后端;
- 中间模块包含一些用于数据库访问和业务逻辑的共享 类。
下面是我的 Build.scala 文件的摘录:
val sharedSettings = Seq(
organization := <organization here>,
version := "1.2.5",
scalaVersion := "2.11.1",
libraryDependencies ++= libraries,
unmanagedJars in Compile ++= baseDirectory.value / "lib",
unmanagedJars in Compile ++= baseDirectory.value / "src",
unmanagedJars in Compile ++= baseDirectory.value / "test"
)
lazy val middle = project.settings(sharedSettings: _*)
lazy val back = project.settings(sharedSettings: _*).dependsOn(middle)
lazy val front =
project
.enablePlugins(play.PlayScala)
.settings(sharedSettings: _*)
.settings(scalaSource in Compile := baseDirectory.value / "app")
.settings(
routesImport ++= Seq(
"scala.language.reflectiveCalls", // Removes warnings when using multiple routes files
"com.asml.cerberus.front.toolbox.Binders._")
)
.dependsOn(middle % "compile->compile;test->test")
我的 application.conf 在 ./front/conf/ 目录中。不幸的是,如果我现在 运行 sbt,它会寻找一个 ./conf/application.conf 文件。 (我已经通过移动 conf 目录对此进行了测试。)
有什么方法可以让 SBT/Play 改用前端模块的 conf 目录?
您可以使用系统属性指定替代配置文件。详情请参阅 here。
如果有帮助,我们有一个围绕激活器 (sbt) activatorWrapper 的包装器脚本:
#!/bin/bash
activator -Dconfig.file=front/conf/application.conf
然后您可以开始您的申请:
$ ./activatorWrapper
我的任务是将旧的 ant 构建脚本重写为 SBT。碰巧,我们的套件由 3 个模块组成:
- Play 2.3 前端网络服务器;
- 从各种其他系统检索数据的后端;
- 中间模块包含一些用于数据库访问和业务逻辑的共享 类。
下面是我的 Build.scala 文件的摘录:
val sharedSettings = Seq(
organization := <organization here>,
version := "1.2.5",
scalaVersion := "2.11.1",
libraryDependencies ++= libraries,
unmanagedJars in Compile ++= baseDirectory.value / "lib",
unmanagedJars in Compile ++= baseDirectory.value / "src",
unmanagedJars in Compile ++= baseDirectory.value / "test"
)
lazy val middle = project.settings(sharedSettings: _*)
lazy val back = project.settings(sharedSettings: _*).dependsOn(middle)
lazy val front =
project
.enablePlugins(play.PlayScala)
.settings(sharedSettings: _*)
.settings(scalaSource in Compile := baseDirectory.value / "app")
.settings(
routesImport ++= Seq(
"scala.language.reflectiveCalls", // Removes warnings when using multiple routes files
"com.asml.cerberus.front.toolbox.Binders._")
)
.dependsOn(middle % "compile->compile;test->test")
我的 application.conf 在 ./front/conf/ 目录中。不幸的是,如果我现在 运行 sbt,它会寻找一个 ./conf/application.conf 文件。 (我已经通过移动 conf 目录对此进行了测试。)
有什么方法可以让 SBT/Play 改用前端模块的 conf 目录?
您可以使用系统属性指定替代配置文件。详情请参阅 here。
如果有帮助,我们有一个围绕激活器 (sbt) activatorWrapper 的包装器脚本:
#!/bin/bash
activator -Dconfig.file=front/conf/application.conf
然后您可以开始您的申请:
$ ./activatorWrapper