springboot服务注册linux服务[测试可用]

基于Linux的Systemd部署

jar: springboot-test.jar

jar所在目录 /opt

在/etc/systemd/system/目录下新建文件springboot-test.service

[Unit]
Description=test
After=syslog.target
 
[Service]
ExecStart= /usr/locl/java -jar /opt/springboot-test.jar
 
[Install]
WantedBy=multi-user.target

java命令要带目录

然后

systemctl daemon-reload

启动:

systemctl start springboot-test

停止:

systemctl stop springboot-test

服务状态:

systemctl status springboot-test

开机启动:

systemctl enable springboot-test

Guess you like

Origin blog.csdn.net/muguku/article/details/120549361