spring boot应用服务化的配置

1、在/etc/systemd/system 目录下创建文件myapp.service

      文件内容:

[Unit]

Description=myapp

After=network.target



[Service]

WorkingDirectory=/var/apps/myapp

ExecStart=/usr/local/java/bin/java -Dsun.misc.URLClassPath.disableJarChecking=true -jar /var/apps/myapp.jar

ExecStop=kill $MAINPID

Restart=always



[Install]

WantedBy=multi-user.target

    需要注意的是需要将myapp改为自己的应用名,ExecStart这个选项中也要将java环境路径以及应用路径改为自己对应的。

2、运行systemctl enable myapp.service,是配置生效

3、可使用systemctl start myapp

                 systemctl stop myapp

                 systemctl restart myapp

      来启动、停止、重启应用

你可能感兴趣的:(spring,boot,服务,配置)