Spring boot部署发布到linux的操作方法
限制条件:
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打包成执行文件
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <executable>true</executable> </configuration> </plugin>
Gradle设置
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可执行文件
[root@i-2cjt6k6n ~]# file audit-console-1.0.0.jar audit-console-1.0.0.jar: Bourne-Again shell script text executable
查看文件内容
vi audit-console-1.0.0.jar
文件开头:

shell与执行jar内容的分割:

可以看到,非常高的技巧,jar包包装为shell可执行文件,另外可以加载自己运行
1.3 发布为一个服务
ln -s /var/myapp/myapp.jar /etc/init.d/myapp service myapp start
总结
上一篇:Java swing实现音乐播放器桌面歌词字体变色效果
栏 目:JAVA代码
下一篇:java控制台输入示例分享
本文标题:Spring boot部署发布到linux的操作方法
本文地址:http://www.codeinn.net/misctech/136166.html


阅读排行
- 1Java Swing组件BoxLayout布局用法示例
- 2java中-jar 与nohup的对比
- 3Java邮件发送程序(可以同时发给多个地址、可以带附件)
- 4Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type异常
- 5Java中自定义异常详解及实例代码
- 6深入理解Java中的克隆
- 7java读取excel文件的两种方法
- 8解析SpringSecurity+JWT认证流程实现
- 9spring boot里增加表单验证hibernate-validator并在freemarker模板里显示错误信息(推荐)
- 10深入解析java虚拟机




