Spring boot部署发布到linux的操作方法

发布时间:2020-10-16 21:47:10 作者:小小她爹
来源:脚本之家 阅读:154

限制条件:

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

文件开头:

Spring boot部署发布到linux的操作方法

shell与执行jar内容的分割:

Spring boot部署发布到linux的操作方法

可以看到,非常高的技巧,jar包包装为shell可执行文件,另外可以加载自己运行 

1.3 发布为一个服务

 ln -s /var/myapp/myapp.jar /etc/init.d/myapp
service myapp start

总结

以上所述是小编给大家介绍的Spring boot部署发布到linux的操作方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对亿速云网站的支持!

推荐阅读:
  1. 为什么说 Java 程序员到了必须掌握 Spring Boot 的时候?
  2. Spring Boot 如何部署到 Linux 中的服务

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

spring boot linux

上一篇:centos下安装配置phpMyAdmin的方法步骤

下一篇:Python利用FFT进行简单滤波的实现

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》