springboot jar注册windows服务(WinSW版)

springboot jar注册windows服务(WinSW版)

1、springboot项目打包可运行的jar,比如jar包名称为sensor01.jar
2、从winsw网站下载WinSw,根据需要选择x64或者x86版本

https://github.com/winsw/winsw/releases

3、把下载的WinSW-x64.exe放到和jar包同一个目录下,并更名为sensor01.exe,同时创建一个同名的配置文件sensor01.xml

4、编辑配置文件sensor01.xml, 可以参照winsw项目里面给出的相关说明进行配置及具体参数的介绍。注意可能需要提前创建日志目录server-logs

https://github.com/winsw/winsw/blob/v2.12.0/doc/installation.md

https://github.com/winsw/winsw/blob/v2.12.0/doc/xmlConfigFile.md

xml 复制代码
<service>
  <id>sensor01</id>
  <name>sensor01</name>
  <description>Sensor01 service</description>
  <executable>C:\Program Files\Java\jdk-17\bin\java.exe</executable>
  <arguments>-jar -Dserver.port=8081 -Xms512m -Xmx512m sensor01.jar</arguments>
  <logpath>E:\sensor01\server-logs\</logpath>
  <log mode="roll"></log>
</service>

5、管理员运行cmd,并切换到jar包所在目录。-?查看相关参数

6、执行install命令,安装服务

7、通过net命令启动、停止服务。或者进入服务管理界面,进行服务的管理,通过日志文件和访问应用程序相关服务,判断服务运行是否正常。

小尾巴~~

只要有积累,就会有进步

相关推荐
王维同学5 分钟前
[自学][Windows C++]RunOnceEx 注册表分组键的安全遍历
c++·windows·安全·开源
钱六两1 小时前
#3、SpringAI 接入deepSeek大模型(喂饭版)
java·spring boot·ai编程
Suhan422 小时前
IDEA 设置启动参数和环境变量
spring boot·spring·编辑器·idea
imatt4 小时前
Qt Creator 在Windows下编译信息乱码
windows·qt
記億揺晃着的那天5 小时前
NAS + Tailscale + WebDAV:安全对接云服务器 Spring Boot
spring boot·tailscale·nas·webdav
就不掉头发5 小时前
计算机的虚拟内存
linux·服务器·windows
橘子海全栈攻城狮5 小时前
【最新源码】基于SpringBoot + Vue的超市管理系统的设计与实现D002
java·开发语言·vue.js·spring boot·后端·spring
其美杰布-富贵-李6 小时前
Spring Boot 中controller、service、mapper
spring boot·python
拾贰_C7 小时前
【Java | SpringBoot | GlobalExceptionHandler】全局异常拦截器实现思路
java·开发语言·spring boot
Lyra_Infra7 小时前
故障排查报告:Spring boot连接 Nacos 异常及启动失败
java·spring boot