一.Springboot java打包jar
比如打包文件为? rescue-0.1.jar
jar存储路径? /home/server/rescue/rescue-0.1.jar
二.建立服务文件
1.进入系统服务配置路径??/etc/systemd/system
2.建立文件rescue.service
3.编辑文件rescue.service,内容如下
[Unit]
Description=My Spring Boot Application
After=network.target
[Service]
User=root
ExecStart=/usr/java/jdk1.8.0_191/bin/java -jar /home/server/rescue/rescue-0.1.jar --spring.pr
WorkingDirectory=/home/server/rescue/
Restart=always
[Unit]
Description=My Spring Boot Application
After=network.target
[Service]
User=root
ExecStart=/usr/java/jdk1.8.0_191/bin/java -jar /home/server/rescue/rescue-0.1.jar --spring.profiles.active=cm
WorkingDirectory=/home/server/rescue/
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rescue
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
?
三.执行配置命令
systemctl daemon-reload
systemctl start rescue.service
systemctl enable rescue.service