spring boot 发布的jar 二 发布到 windows

1.使用 winsw 发布

  下载地址 https://github.com/winsw/winsw/releases

  文档地址:https://github.com/winsw/winsw

1.1 下载:

  下载最新版本即可,下载exe可执行文件,并下载示例,注意 .net 的版本,window没有的话就按照对应版本的 .net framework:  

 

 

 

2. 配置文件、exe文件、jar 包放到同一文件夹下

3.修改WinSW.NET4.exe文件的名称 为 metadata-web.exe 和配置文件的名称  metadata-web.xml ,名称要相同

 把配置文件放到此文件夹下,如:

 

4.修改配置文件

<service>
  <!-- ID of the service. It should be unique across the Windows system-->
  <id>microservice-metadataweb</id>
  <!-- Display name of the service -->
  <name>microservice-metadataweb</name>
  <!-- Service description -->
  <description>元数据管理系统后台8082</description>
  <env name="JENKINS_HOME" value="%BASE%"/>
  <executable>java</executable>  
  <arguments>-Xrs -Xmx512M -Xms512M -XX:MaxMetaspaceSize=128M -XX:MetaspaceSize=128M -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:+ParallelRefProcEnabled -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:log\metadataweb.gc.log -jar "%BASE%\metadata-web-1.0-SNAPSHOT.jar"  --spring.config.location=%BASE%\portal-application.yml</arguments>
  <logpath>%BASE%\log</logpath>
  <log mode="roll"></log>
</service>

备注:

  1. id 和 name 服务中必须唯一,

  2. arguments 中修改jar包的名称和文件夹中jar包相同

  3. 配置好log路径

  4. 配置文件名称要和文件夹中的配置文件对应,程序启动时,会读入文件夹中的配置文件,替代程序中的配置文件,

发布 exe :

<service>
 
  <!-- ID of the service. It should be unique across the Windows system-->
  <id>SpyService</id>
  <!-- Display name of the service -->
  <name>SpyService</name>
  <!-- Service description -->
  <description>智能硬件监控系统</description>

  <executable>%BASE%\spy.exe</executable>
  <arguments>-s 192.168.17.24 -p 18000</arguments>
  <logpath>%BASE%\log</logpath>
  <logmode>roll</logmode>
</service>

 

 

5.cmd 进入到文件夹目录

 

 

 执行命令:metadata-web.exe install    创建服务

metadata-web.exe start 启动

metadata-web.exe restart 重启

metadata-web.exe help  查看命令

 

posted @ 2020-06-23 17:59  leolzi  阅读(315)  评论(0编辑  收藏  举报