我想通过 sbt 到WAR文件而不是JAR文件,我按照这个 指南.
我已经改变了 build.sbt
到。
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-jetty" % Http4sVersion,
"org.http4s" %% "http4s-jetty-client" % Http4sVersion,
"org.http4s" %% "http4s-circe" % Http4sVersion,
"org.http4s" %% "http4s-dsl" % Http4sVersion,
"io.circe" %% "circe-generic" % CirceVersion,
"org.specs2" %% "specs2-core" % Specs2Version % "test",
"ch.qos.logback" % "logback-classic" % LogbackVersion
),
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3"),
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
// disable .jar publishing
Compile / packageBin / publishArtifact := false,
// create an Artifact for publishing the .war file
Compile / packageWar / artifact := {
val prev: Artifact = (Compile / packageWar / artifact).value
prev.withType("war").withExtension("war")
},
// add the .war file to what gets published
addArtifact(Compile / packageWar / artifact, packageWar),
)
而编译器却在抱怨
/home/developer/scala/user-svc/build.sbt:27: error: not found: value packageWar
Compile / packageWar / artifact := {
^
/home/developer/scala/user-svc/build.sbt:28: error: not found: value packageWar
val prev: Artifact = (Compile / packageWar / artifact).value
^
/home/developer/scala/user-svc/build.sbt:33: error: not found: value packageWar
addArtifact(Compile / packageWar / artifact, packageWar),
^
/home/developer/scala/user-svc/build.sbt:33: error: not found: value packageWar
addArtifact(Compile / packageWar / artifact, packageWar),
我到底做错了什么?
在文档中存在一个错误--见 https:/github.comsbtsbtissues4490。
试试使用专用的sbt插件- xsbt-web-plugin - 而不是阅读该网站。据 现行文件 您需要添加到 project/plugins.sbt
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.2.0")
然后启用插件在 build.sbt
如:码头
enablePlugins(JettyPlugin)
然后,你可以建立战争与 package
命令。