这里说的可执行jar是说在shell下直接输入xxx.jar,然后直接运行程序。
主要原理就是将一个可执行脚本与jar文件合并到一个文件。假设可执行文件为start.sh,jar文件为helloworld.jar。执行下面脚本:
cat start.sh helloworld.jar > helloworld.run.jar && chmod +x helloworld.run.jar.
生成的helloworld.run.jar可以直接在linux下运行。
可以参考:
https://coderwall.com/p/ssuaxa/how-to-make-a-jar-file-linux-executable
https://www.linuxjournal.com/content/add-binary-payload-your-shell-scripts
sping boot项目可参考
https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-jersey