运行Spring Boot App作为服务

时间:2016-06-02 07:56:52

标签: spring unix spring-boot

我希望运行我的Spring Boot应用程序作为服务我在/etc/systemd/system

上创建此脚本
[Unit]
Description=Application_Test
After=syslog.target

[Service]
User=jenkins
ExecStart=java -jar /var/myapp/app.war
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

运行此命令:

systemctl enable myapp.service

我开始了

service start myapp

我有这个错误:

Redirecting to /bin/systemctl start  myapp.service
Failed to issue method call: Unit myapp.service failed to load: Invalid argument. 

有什么问题?

1 个答案:

答案 0 :(得分:0)

我忘了在我的脚本中查询JDK的方式

[Unit]
    Description=Application_Test
    After=syslog.target

    [Service]
    User=jenkins
    ExecStart=/usr/bin/java -jar /var/myapp/app.war
    SuccessExitStatus=143

    [Install]
    WantedBy=multi-user.target