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 @   leolzi  阅读(331)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示