How to create executable single jar which include webapp resources by sbt-assembly with scalatra

你离开我真会死。 提交于 2020-02-24 09:29:12

问题


I'm making webapp using scalatra framework via sbt & xsbt-web-plugin.

I want to package all resources(templates, css, js) into a single jar.

In sbt with sbt-assembly plugin, assembly command makes single jar which includes all of project's dependencies.

$ java -jar myproject.jar

and I open it in browser

Could not load resource: [/WEB-INF/views/index.scaml]; are you sure it's within [null]?

I unzipped jar to confirm that it does not include src/main/webapp/*.

How can I config sbt for including src/main/webapp/* and building executable jar?


回答1:


Resources are meant to be put under the resources folders. There are two such folders:

  • src/main/resources for resources available at runtime
  • src/test/resources for resources available only during testing

sbt will package those automatically for you when you run package-war or test. The project does not need to have the assembly plugin for sbt to include resources.

In your case, you should put the WEB-INF directory in src/main/resources/WEB-INF/.



来源:https://stackoverflow.com/questions/8374174/how-to-create-executable-single-jar-which-include-webapp-resources-by-sbt-assemb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!