[Java] 将jar以服务方式部署到ubuntu
文章目录
1.安装jdk
apt install openjdk-11-jdk2.创建服务配置文件
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.target3.更新、运行、启动服务配置
systemctl daemon-reload
systemctl enable my_service.service
systemctl start my_service.service
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论