springboot jar包安装成windows服务

900 阅读1分钟

下载exe repo.jenkins-ci.org/releases/co…

本文下载了winsw-2.3.0-bin.exe。

新建一个目录autService

在目录里面新建一个autService.xml,同时把winsw-2.3.0-bin.exe重命名陈autService.exe

必须这么做,否则无法安装启动服务。

编辑autService.xml文件

<?xml version="1.0" encoding="utf-8" ?>
<service>
	<!-- 服务id(必须唯一) -->
    <id>nongyeServer</id> <!-- must be unique -->
	<!-- 显示的服务名 -->
    <name>nongyeServer</name>
	<!-- 显示的服务描述 -->
    <description>服务描述</description>
    <executable>javaw</executable>
	<!-- 替换自己的jar -->
    <arguments>-jar "%BASE%\nongye.jar"</arguments>
    <logpath>%BASE%\log</logpath>
    <log mode="roll-by-time">
    <pattern>yyyy-MM-dd</pattern>   
    </log>
</service>

(注:此处注意,如果用的是文本编辑器修改,务必将编码格式换成Unicode编码)

用管理方式启动控制台(cmd),切换到该文件夹内

安装服务命令

autService.exe install

卸载服务命令

autService.exe uninstall

安装完,在系统服务里可以看到已经安装的服务

参考:blog.csdn.net/qq_41618510…

www.cnblogs.com/passedbylov…