关于java:Java-将jar以服务方式部署到ubuntu

3次阅读

共计 434 个字符,预计需要花费 2 分钟才能阅读完成。

1. 装置 jdk

apt install openjdk-11-jdk

2. 创立服务配置文件

vim /ect/systemd/system/my_service.service

追加以下内容

[Unit]
Description=My Java Service
[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/server
ExecStart=/usr/bin/java -jar /home/ubuntu/server/main.jar
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target

3. 更新、运行、启动服务配置

systemctl daemon-reload
systemctl enable my_service.service
systemctl start my_service.service
正文完
 0