Create standalone jar using SBT

前端 未结 5 928
孤独总比滥情好
孤独总比滥情好 2020-12-23 13:24

I was a heavy Maven user and now I\'m gradually using SBT for some of my projects.

I\'d like to know how could I use SBT to create a standalone Java project? This pr

5条回答
  •  春和景丽
    2020-12-23 14:17

    Sure, you can use 'sbt package' command, it creates a jar file but this jar will be without any dependencies. To run it necessary to specify 'classpath' arg to the libraries.

    In your case you wish a standalone runnable file. And you need to add the dependencies. To do this you can use 'assembly' plugin for SBT, see https://github.com/sbt/sbt-assembly/

    Afterward you can just run 'sbt assembly' command, it provides a fat jar file with all dependencies that you can deploy and run anywhere and at any time.

    For details see this article

提交回复
热议问题