Spring-Boot项目编译的jar在windows下作为service执行

技术文档网 2021-04-28

可以使用Windows service wrapper来把任何命令行执行的程序做成windows service.

Windows Service Wrapper简称WinSW,可以在https://github.com/kohsuke/winsw/releases 下载到

编写一个配置文件

编写一个xml文件,可参照下例:

<configuration>
  <id>tutorial-service</id>
  <name>Tutorial Service</name>
  <description></description>
  <executable>java</executable>
  <arguments>-jar c:\tutorial\tutorial-section-01-1.0-SNAPSHOT.jar</arguments>
  <logmode>rotate</logmode>
</configuration>

文件保存为 tutorial-service.xml,然后把winsw.exe拷贝到相同目录下,并改成和xml一样的名字(扩展名仍旧是exe不变)tutorial-service.exe

安装service和卸载service

在命令行下执行

tutorial-service.exe install

可把前面设置的xml中命令安装为windows service(执行上述命名需要具有windows管理员权限。

如果需要卸载可用

tutorial-service.exe uninstall

相关文章

  1. 基于-SLF4J-MDC-机制的日志链路追踪配置属性

    ums: # ================ 基于 SLF4J MDC 机制的日志链路追踪配置属性 ================ mdc: # 是否支持基于 SLF4J MDC

  2. ajax-跨域访问

    ajax 跨域访问 &lt;!DOCTYPE html&gt; &lt;html xmlns:th="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt;

  3. 给第三方登录时用的数据库表-user_connection-与-auth_token-添加-redis-cache

    spring: # 设置缓存为 Redis cache: type: redis # redis redis: host: 192.168.88.88 port

  4. Java动态代理

    Jdk动态代理 通过InvocationHandler和Proxy针对实现了接口的类进行动态代理,即必须有相应的接口 应用 public class TestProxy { public

  5. Java读取classpath中的文件

    public void init() { try { //URL url = Thread.currentThread().getContextClassLo

随机推荐

  1. 基于-SLF4J-MDC-机制的日志链路追踪配置属性

    ums: # ================ 基于 SLF4J MDC 机制的日志链路追踪配置属性 ================ mdc: # 是否支持基于 SLF4J MDC

  2. ajax-跨域访问

    ajax 跨域访问 &lt;!DOCTYPE html&gt; &lt;html xmlns:th="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt;

  3. 给第三方登录时用的数据库表-user_connection-与-auth_token-添加-redis-cache

    spring: # 设置缓存为 Redis cache: type: redis # redis redis: host: 192.168.88.88 port

  4. Java动态代理

    Jdk动态代理 通过InvocationHandler和Proxy针对实现了接口的类进行动态代理,即必须有相应的接口 应用 public class TestProxy { public

  5. Java读取classpath中的文件

    public void init() { try { //URL url = Thread.currentThread().getContextClassLo