碰到一次服务器为windows的,客户要求把java程序做成windows服务。
我用了 winsw 去实现,下载地址:https://github.com/kohsuke/winsw/releases
下载后改名,改成和jar包名称一样,同事创建和jar名称一样的xml配置文件
<configuration>
<id>test</id>
<name>test</name>
<description>test</description>
<executable>E:\JDK\jdk180131\bin\java</executable>
<arguments>-jar %BASE%\test.jar</arguments>
<logpath>%BASE%\serviceLog</logpath>
<logmode>rotate</logmode>
</configuration>
id:安装windows服务后的服务ID,必须是唯一的。
name:服务名称,也必须是唯一的。一般和id一致即可。