BYTECODES

Linux配置Spring Boot Jar开机启动服务

在/etc/systemd/system目录下新建启动脚本,后缀是xxx.service, xxx可以是任意名称,输入以下内容

[Unit]
Description=abc springboot project
After=syslog.target
 
[Service]
Type=simple
ExecStart=/usr/local/jdk17/bin/java -jar /usr/local/abc-1.0.jar &
 
[Install]
WantedBy=multi-user.target

接着按次序执行下面命令

chmod +x /usr/lib/systemd/system/xxx.service
systemctl daemon-reload
systemctl enable xxx.service

如果想手动开启服务,可以执行下面命令

systemctl start xxx.service

使用下面命令查看服务状态

systemctl status xxx.service