本文介绍了sbt-assembly:如何在 src/main/webapp 中包含静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用来自 https://github.com/sbt/sbt-assembly 的 sbtassembly使用此合并策略:

I am using sbtassembly from https://github.com/sbt/sbt-assembly with this merge strategy:

mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
  {
    case PathList("javax", "servlet", xs @ _*)         => MergeStrategy.first
    case PathList(ps @ _*) if ps.last endsWith ".html" => MergeStrategy.first
    case "application.conf" => MergeStrategy.concat
    case "unwanted.txt"     => MergeStrategy.discard
    case x => old(x)
  }
}

由于某种原因,我的静态内容没有包含在可执行 jar 中,但我的网络服务工作正常(所以它确实工作).

For some reason my static content is not being included in the executable jar, but my webservices work fine (so it does work).

如何包含我的 index.html 和 javascript 文件?

How can I include my index.html and javascript files?

推荐答案

有一个相关的问题 为什么 sbt compile 不会将非托管资源复制到类路径?您可以了解设置.

There's a related question Why sbt compile doesn't copy unmanaged resources to classpath? that you can get an idea for the setting.

这是使用 sbt 0.13 的设置:

Here's the setting using sbt 0.13:

unmanagedResourceDirectories in Compile += { baseDirectory.value / "src/main/webapp" }

这篇关于sbt-assembly:如何在 src/main/webapp 中包含静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 10:28