限制條件:
The default script supports most Linux distributions and is tested on CentOS and Ubuntu. Other platforms, such as OS X and FreeBSD, will require the use of a custom embeddedLaunchScript.
當前文檔適用于 CentOS and Ubuntu,其他平臺需要定制腳本
1、部署發布
1.1 打包
maven打包成執行文件
1
2
3
4
5
6
7
|
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <executable> true </executable> </configuration> </plugin> |
Gradle設置
1
2
3
|
springBoot { executable = true } |
You can then run your application by typing ./my-application.jar (where my-application is the name of your artifact).
打包完成后,可以使用./my-application.jar 運行
1.2 原理
linux下查看文件格式為一個bshell可執行文件
1
2
|
[root @i -2cjt6k6n ~]# file audit-console- 1.0 . 0 .jar audit-console- 1.0 . 0 .jar: Bourne-Again shell script text executable |
查看文件內容
1
|
vi audit-console- 1.0 . 0 .jar |
文件開頭:
shell與執行jar內容的分割:
可以看到,非常高的技巧,jar包包裝為shell可執行文件,另外可以加載自己運行
1.3 發布為一個服務
1
2
|
ln -s /var/myapp/myapp.jar /etc/init.d/myapp service myapp start |
總結
以上所述是小編給大家介紹的Spring boot部署發布到linux的操作方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對服務器之家網站的支持!