在/etc/systemd/system新建boot.service文件,填入如下内容。 [Unit] Description=a After=syslog.target mysqld.service [Install] WantedBy=multi-user.target [Service] WorkingDirectory=/home/test/boot/a User=test Group=test Type=simple # Start main service ExecStart=/usr/local/env/java/jdk1.8.0_171/bin/java -jar /home/test/boot/a/a.jar # EnvironmentFile=/home/test/boot/a/application.yml ExecStop=kill $MAINPID #Restart=always 相关命令 设置自启动:systemctl enable boot 移除自启动:systemctl disable boot 启动:systemctl startr boot 停止:..... SpringBoot通过systemctl自启动 linux