导读:文章目录 前期准备 打包成可执行jar包 注册成为liunx服务 System V Init Systemd Upstart 在Windows中安装 Windows Service Wrapper Java Service Wrapper 将Spring Boot应用程序注册成为系统服务 在之前的文章中,我们提到了很多Spring Boot的技巧,那么当
# Place in /home/{user}/.config/upstart
description "Some Spring Boot application"
respawn # attempt service restart if stops abruptlyexec java -jar /path/to/your-app.jar
在Windows中安装
在windows中,我们也有很多方式,如下:
Windows Service Wrapper
Windows Service Wrapper 又叫 winsw是一个开源软件,winsw需要和一个配置文件your-app.xml配合使用:
<service><id>MyApp</id><name>MyApp</name><description>This runs Spring Boot as a Service.</description><envname="MYAPP_HOME"value="%BASE%"/><executable>java</executable><arguments>-Xmx256m -jar "%BASE%your-app.jar"</arguments><logmode>rotate</logmode></service>