文章来源:https://www.baeldung.com/spring-boot-app-as-a-service#1-windows-service-wrapper
1.Windows服务包装器
- 下载二进制文件winsw
- 编写SpringBoot Jar包项目构建配置
<service>
<id>MyApp</id>
<name>MyApp</name>
<description>This runs Spring Boot as a Service.</description>
<env name="MYAPP_HOME" value="%BASE%"/>
<executable>java</executable>
<arguments>-Xmx256m -jar "%BASE%\MyApp.jar"</arguments>
<logpath>./winsw-log/</logpath>
<logmode>rotate</logmode>
</service>
- 重命名winsw.exe到MyApp.exe,匹配MyApp.xml配置文件
- 安装服务
MyApp.exe install
- 同样,您可以使用uninstall,start,stop等