[英]How to create executable single jar which include webapp resources by sbt-assembly with scalatra
I'm making webapp using scalatra framework via sbt & xsbt-web-plugin. 我正在通过sbt和xsbt-web-plugin使用scalatra框架制作webapp。
I want to package all resources(templates, css, js) into a single jar. 我想将所有资源(模板,css,js)打包到一个jar中。
In sbt with sbt-assembly plugin, assembly
command makes single jar which includes all of project's dependencies. 在使用sbt-assembly插件的sbt中, assembly
命令使单个jar包含所有项目的依赖项。
$ java -jar myproject.jar
and I open it in browser 我在浏览器中打开它
Could not load resource: [/WEB-INF/views/index.scaml]; 无法加载资源:[/ WEB-INF/views/index.scaml]; are you sure it's within [null]? 你确定它在[null]之内吗?
I unzipped jar to confirm that it does not include src/main/webapp/*
. 我解压缩jar以确认它不包含src/main/webapp/*
。
How can I config sbt for including src/main/webapp/*
and building executable jar? 如何配置sbt包含src/main/webapp/*
和构建可执行jar?
Resources are meant to be put under the resources
folders. 资源应放在resources
文件夹下。 There are two such folders: 有两个这样的文件夹:
src/main/resources
for resources available at runtime src/main/resources
用于运行时可用的资源 src/test/resources
for resources available only during testing src/test/resources
仅用于测试期间可用的资源 sbt will package those automatically for you when you run package-war
or test
. 当你运行package-war
或test
时,sbt会自动为你package-war
。 The project does not need to have the assembly plugin for sbt to include resources. 该项目不需要让sbt的程序集插件包含资源。
In your case, you should put the WEB-INF
directory in src/main/resources/WEB-INF/
. 在您的情况下,您应该将WEB-INF
目录放在src/main/resources/WEB-INF/
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.