@凯尔西吉尔莫-因尼斯 https://stackoverflow.com/a/18884064/3827有正确的答案,但既然它不被接受,让我们打破它,打破它,打破它。
首先,我假设你正在关注入门指南 http://www.scalatra.org/2.2/getting-started/first-project.html使用以下命令安装 Scalatrag8
。希望和我刚拿到的版本是一样的。
g8 scalatra/scalatra-sbt
g8 模板所做的是设置一个 sbt 0.13 版本,它使用scalatra-sbt https://github.com/scalatra/scalatra-sbt0.3.2插件:
addSbtPlugin("org.scalatra.sbt" % "scalatra-sbt" % "0.3.2")
该插件内部使用JamesEarlDouglas/xsbt-web-plugin https://github.com/JamesEarlDouglas/xsbt-web-plugin0.4.0 做webapp相关的设置。
xsbt-web-插件 0.4.0
这就是为什么 xsbt-web-plugin 变得相关,即使您只想更改 Scalatra 的设置。您需要重新连线的设置称为webappResources in Compile
。这是如何运作的?
重新连接 webapp 资源
要重新连接设置,请打开project/build.scala
. Add
import com.earldouglas.xsbtwebplugin.PluginKeys.webappResources
到进口条款。然后按如下方式更改设置:
lazy val project = Project (
"foo",
file("."),
settings = Defaults.defaultSettings ++ ScalatraPlugin.scalatraWithJRebel ++ scalateSettings ++ Seq(
organization := Organization,
name := Name,
version := Version,
scalaVersion := ScalaVersion,
resolvers += Classpaths.typesafeReleases,
webappResources in Compile := Seq(baseDirectory.value / "content" / "doc-root"),
...
)
)
现在移动src/main/webapp
to content/doc-root
,重新加载sbt,应该就可以了。