SpringBoot Centos6.x 设置为系统服务

1、首先修改pom.xml  true 这样编译的jar会包含shell脚本


    org.springframework.boot
    spring-boot-maven-plugin
     
         true
     

2、上传jar包服务器,路径任意,我这里是/home/springboot

lnyd_broadband-1.0-SNAPSHOT.jar

chmod 500 lnyd_broadband-1.0-SNAPSHOT.jar #添加可执行权限

3、编写jar的配置文件,需要与jar包同名,后缀名.conf

lnyd_broadband-1.0-SNAPSHOT.conf

JAVA_HOME="/opt/jdk/jdk1.8.0_181"
JAVA_OPTS="-server -Xms1G -Xmx1G"
RUN_ARGS="--spring.config.location=application-dev.properties"
LOG_FOLDER="./"
PID_FOLDER="./"

chmod 400 lnyd_broadband-1.0-SNAPSHOT.conf #添加权限

4、添加链接到/etc/init.d/

ln -s /home/springboot/lnyd_broadband-1.0-SNAPSHOT.jar /etc/init.d/lnyd

5、启动 停止

service lnyd start

service lnyd stop

 

技术交流群:212320390

参考官方文档

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#deployment-install

 

nohup java -jar sce-0.0.1-SNAPSHOT.jar --server.port=9091 2>&1 &

你可能感兴趣的:(JAVA)