通过 winsw工具把jar包安装成服务,自启动、通过下面地址下载文件。
https://github.com/kohsuke/winsw/releases
电脑要安装 .net 环境 .net 版本为2则用winsw.net2 为4则用winsw.net4
把exe文件改成 server.ext 可以根据自己命名
创建一个xml文件 server.xml
<configuration>
<!-- ID of the service. It should be unique accross the Windows system-->
<id>nurseAdminServer</id>
<!-- Display name of the service -->
<name>nurseAdminServer Service </name>
<!-- Service description -->
<description>This service is a service nurseAdminServer</description>
<!-- Path to the executable, which should be started -->
<executable>C:\Java\jdk1.8.0_05\bin\java.exe</executable>
<!--Xmx256m 代表堆内存最大值为256MB -jar后面的是项目名-->
<arguments>-Xmx512m -jar nurse-admin.jar</arguments>
<!-- 日志文件-->
<logpath>%BASE%\logs</logpath>
<!--日志模式-->
<logmode>rotate</logmode>
</configuration>
安装服务:
server.exe install
到服务里查看是否安装成功,右击启动java项目
卸载服务
server.ext. uninstall