我在Digital Ocean droplet上有一个Spring Boot可执行jar文件。我能够使用 java -jar myapp.jar
命令执行该jar文件。现在我想将其作为一个服务运行。
我创建了文件/etc/systemd/system/myapp.service,内容如下:
[Unit]
Description=myapp
After=syslog.target
[Service]
User=kevin
ExecStart=/var/myapp/myapp-backend-1.0-SNAPSHOT.jar
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
然后启用它以在系统启动时自动运行。
systemctl enable myapp.service
我现在正在尝试启动该服务
systemctl start myapp.service
但我遇到了这个错误
无法启动myapp.service:未知单元:myapp.service 请查看系统日志和“systemctl status myapp.service”获取详细信息。
运行systemctl status myapp.service
返回以下内容:
Failed to get properties: No such interface ''