当前位置:网站首页>将jar包注册为服务,实现开机自动启动
将jar包注册为服务,实现开机自动启动
2022-06-25 08:28:00 【String-int】
1、使用winsw

将这两个下载
1、放在和jar包的同一目录下
2、将上面这两个文件重命名为服务名(可以随便起,只要不和电脑上的服务名重名就行了)
3、修改xml文件(用的时候注释里面不要有中文)
<!-- 这是一个最小的Windows Service Wrapper配置示例,其中仅包括强制选项。 此配置文件应放在WinSW可执行文件附近,名称应相同。 E、 g.对于myapp。exe配置文件名应为myapp。xml 您可以在此处找到有关配置选项的更多信息:https://github.com/kohsuke/winsw/blob/master/doc/xmlConfigFile.md 完整示例:https://github.com/kohsuke/winsw/blob/master/examples/sample-allOptions.xml -->
<service>
<!-- 服务的ID。它在整个Windows系统中应该是唯一的-->
<id>CacheMain</id>
<!-- 服务的显示名称 -->
<name>CacheMainService</name>
<!-- 服务描述 -->
<description>This service is a service created from a minimal configuration</description>
<!-- java环境变量 -->
<env name="JAVA_HOME" value="%JAVA_HOME%"/>
<executable>java</executable>
<arguments>-jar "D:\workspace\practice\Cache\target\Cache - 1.0.1.jar" --xx</arguments>
<!-- 开机启动-->
<startmode>Automatic</startmode>
</service>
1、<id>和<name>标签中的内容建议设置和exe和xml文件一样的,如我这里是Cache.exe和Cache.xml,所以设置为Cache和CacheService,不能和已存在服务重名
2、<arguments>标签引号中的jar包地址和名称需要替换成自己的,如果启动命令不是java -jar "xxx",而是java -jar "xxx" --xx,将--xx跟在引号后面即可。如<arguments>-jar "C:\Windows\System32\cmd.exe\CollectionGrapthMap.jar" --xx</arguments>
3、安装服务
在exe所在目录执行CacheMain.exe install ,Cache名自己替换,如需要卸载输入CacheMain.exe uninstall
4、启动服务
win+r,输入services.msc,查找到自己刚安装的服务,右键启动
注意:一个jar包只能注册为一个服务
边栏推荐
- annotation lib 和 processor lib如何引用
- 股票在线开户安全吗?找谁可以办理?
- cazy長安戰役八卦迷宮
- nodejs 使用Express框架demo
- 从别人库里拷贝的游戏如何再自己的库里显示
- 《乔布斯传》英文原著重点词汇笔记(六)【 chapter three 】
- C # startup program loses double quotation marks for parameters passed. How to solve it?
- Openfoam: bottom layer
- atguigu----18-组件
- Is the client that gets the scanning code wechat or Alipay
猜你喜欢

自定义注解之编译时注解(RetentionPolicy.CLASS)

Jmeter中的断言使用讲解

atguigu----17-生命周期

C#启动程序传递参数丢失双引号,如何解决?
![[final review notes] digital logic](/img/57/4431208b1c8b653f5c3f4ff4212cc3.png)
[final review notes] digital logic

Matplotlib plt Axis() usage

compiling stm32f4xx_ it. c... “.\Objects\BH-F407.axf“ - 42 Error(s), 1 Warning(s).

How can games copied from other people's libraries be displayed in their own libraries

On the underlying index principle of MySQL

【OpenCV】—输入输出XML和YAML文件
随机推荐
C language: find all integers that can divide y and are odd numbers, and put them in the array indicated by B in the order from small to large
行业春寒回暖,持续承压的酒店企业于何处破局?
Explanation of assertions in JMeter
十大券商开户风险大吗,安全靠谱吗?
打新债安全性有多高啊
Make a skylearn high-dimensional dataset_ Circles and make_ moons
IC研发常用英文术语缩写
106. 简易聊天室9:使用 Socket 传递音频
从别人库里拷贝的游戏如何再自己的库里显示
Where are the hotel enterprises that have been under pressure since the industry has warmed up in spring?
3大问题!Redis缓存异常及处理方案总结
Compile time annotations for custom annotations (retentionpolicy.class)
自定义注解之编译时注解(RetentionPolicy.CLASS)
Lvs-dr mode multi segment case
二、训练fashion_mnist数据集
matplotlib matplotlib中plt.axis()用法
1、 Construction of single neural network
C program termination problem clr20r3 solution
Specific usage of sklearn polynomialfeatures
The meshgrid() function in numpy