一、准备NSSM
nssm官网地址http://www.nssm.cc/, 下载地址 http://www.nssm.cc/release/nssm-2.24.zip 。加载并解压。
二、准备可运行.bat脚本
将打包好的jar包放到一个文件夹中,编写run.bat文件,run.bat内容为
java -jar xxxx.jar
三、设置nssm服务
从第一步中下载解压的文件找到nssm.exe文件,用管理员运行的cmd窗口,输入命令:nssm.exe install
会出现服务安装界面
![](https://xuyongsheng.cn/wp-content/uploads/2022/02/image-3-1024x623.png)
![](https://xuyongsheng.cn/wp-content/uploads/2022/02/image-4-1024x589.png)
![](https://xuyongsheng.cn/wp-content/uploads/2022/02/image-5-1024x630.png)
![](https://xuyongsheng.cn/wp-content/uploads/2022/02/image-6-1024x585.png)
完成上面配置点击“Install service”即可完成服务安装。
![](https://xuyongsheng.cn/wp-content/uploads/2022/02/image-7-1024x568.png)