linux下springBoot项目设置成服务开机自启

1.进入服务文件目录

cd /etc/systemd/system/

2.创建文件

vim my-apps.service

#添加下面内容
[Unit] 
Description=ms-file
After=syslog.target

[Service] 
ExecStart=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64/jre/bin/java -jar /usr/local/apps/my-apps.jar --server.tomcat.basedir=/tmp/tomcat --spring.profiles.active=huizhou --jasypt.encryptor.password=hnkc

[Install] 
WantedBy=multi-user.target

3.开机自启

systemctl enable my-apps

4.启动项目

systemctl start my-apps

5.查看启动状态

systemctl status my-apps

6.停止项目

systemctl stop my-apps

7.取消开机自启

systemctl disable my-apps

推荐阅读更多精彩内容