使用winsw
下载
https://github.com/winsw/winsw/releases
相关文档地址
https://github.com/winsw/winsw
新建XML
相关介绍
https://github.com/winsw/winsw/blob/v3/docs/xml-config-file.md
使用
要使用winsw,电脑上必须已经安装`.NET framework
1,将jar包和winsw放在同一目录。
2,然后将winsw重命名为和自己jar包一样的名字。
3,在当前目录下新建一个xml文件,这个xml文件也和jar包的名字一样
<xml>
<service>
<id>test</id>
<name>test-dev</name>
<description>This service runs test project.</description>
<executable>java</executable>
<arguments>-jar "test.jar"</arguments>
<logmode>rotate</logmode>
</service>
</xml>
命令行定位到当前目录:关闭360
输入命令:test.exe install
启动
原因:XML 有问题
解决
<!-- 服务ID,在windows系统中必须唯一 -->
<!-- 服务显示名称,只能英文和数字 -->
<!-- 服务描述,只能英文和数字 -->
新xml
<xml>
<service>
<id>test</id>
<name>testdev</name>
<description>This service runs test project.</description>
<executable>java</executable>
<arguments>-jar "test.jar"</arguments>
<logmode>rotate</logmode>
</service>
</xml>
删除之前的 重新安装启动
除了install命令外,还有其它命令:
uninstall:删除服务
start:启动服务
stop:停止服务
restart:重启服务
status:输出当前服务的状态