简体   繁体   中英

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.

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?

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/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM