windows下通过winsw将SpringBoot可运行jar包做成后台服务,启动运行

1.通过maven打包SpringBoot打包jar。

2.电脑上安装 .net framework4 。

3.下载winsw 点这下载

4.

.

5.下载的sample-minimal.xml、WinSW.NET4.exe和已经打包好的 Test-0.0.1-SNAPSHOT.jar放在同一文件夹下,

sample-minimal.xml、WinSW.NET4.exe重命名为Test-0.0.1-SNAPSHOT.xml和Test-0.0.1-SNAPSHOT.exe。

6.

<!--
    Copyright (c) 2016 Oleg Nenashev and other contributors

    Permission is hereby granted, free of charge, to any person obtaining a copy of this 
    software and associated documentation files (the "Software"), to deal in the Software without
    restriction, including without limitation the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or 
    substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
    BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
    DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<!--
 This is an example of a minimal Windows Service Wrapper configuration, which includes only mandatiory options.
 
 This configuration file should be placed near the WinSW executable, the name should be the same.
 E.g. for myapp.exe the configuration file name should be myapp.xml
 
 You can find more information about the configuration options here: https://github.com/kohsuke/winsw/blob/master/doc/xmlConfigFile.md
 Full example: https://github.com/kohsuke/winsw/blob/sample-config-file/examples/allOptions.xml
-->
<configuration>
  
  <!-- ID of the service. It should be unique accross the Windows system-->
  <!--服务ID:启动、关闭、删除服务时,都是通过ID来操作的-->
  <id>Test-0.0.1-SNAPSHOT</id>
  <!-- Display name of the service -->
  <!--服务名称-->
  <name>Test-0.0.1-SNAPSHOT (powered by WinSW)</name>
  <!-- Service description -->
  <!--服务描述-->
  <description>This service is a service cratead from a minimal configuration</description>
  
  <!-- Path to the executable, which should be started -->
  <executable>java</executable>
  <!--启动参数-->
  <arguments>-jar Test-0.0.1-SNAPSHOT.jar</arguments>
  <!--<arguments>-jar "C:\Users\Administrator\Desktop\winsw\Test-0.0.1-SNAPSHOT.jar"</arguments>-->
  <!--日志配置-->
  <logmode>rotate</logmode>

</configuration>

7.通过cmd进入文件夹(cmd最好用管理员权限启动,不然安装服务时候会被拒绝)

cmd-进入文件- 执行命令:Test-0.0.1-SNAPSHOT.exe install

8.安装成功后,手动在服务界面启动,或者通过命令:net start Test-0.0.1-SNAPSHOT          (服务ID)启动服务。

9.通过命令:net stop statement-0.0.1-SNAPSHOT 停止服务,或者是直接去服务界面手动停止服务。

10.停止服务后,可通过:sc delete ServiceName删除服务

写个记录~

参考bighuan 作者 《通过winsw将SpringBoot可运行jar包做成后台服务,启动运行

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值