当前位置:网站首页>将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包只能注册为一个服务
边栏推荐
- 《乔布斯传》英文原著重点词汇笔记(六)【 chapter three 】
- In Section 5 of bramble pie project practice, Nokia 5110 LCD is used to display Hello World
- WebGL谷歌提示内存不够(RuntimeError:memory access out of bounds,火狐提示索引超出界限(RuntimeError:index out of bounds)
- How to become a software testing expert? From 3K to 17k a month, what have I done?
- 某视频网站m3u8非感知加密分析
- 声纹技术(七):声纹技术的未来
- How to solve the 10061 error of MySQL in Linux
- How to increase the monthly salary of software testing from 10K to 30K? Only automated testing can do it
- 自定义注解之编译时注解(RetentionPolicy.CLASS)
- A 35 year old Tencent employee was laid off and sighed: a suite in Beijing, with a deposit of more than 7 million, was anxious about unemployment
猜你喜欢

Matplotlib plt Axis() usage

JMeter interface test, associated interface implementation steps (token)

Matplotlib simple logistic regression visualization

Mapping mode of cache

Compile time annotations for custom annotations (retentionpolicy.class)

In Section 5 of bramble pie project practice, Nokia 5110 LCD is used to display Hello World

Matplotlib decision boundary drawing function plot in Matplotlib_ decision_ Boundary and plt Detailed explanation of contour function

Easyplayer streaming media player plays HLS video. Technical optimization of slow starting speed

RMB 3000 | record "tbtools" video, make a friend and get a cash prize!

matplotlib matplotlib中plt.axis()用法
随机推荐
C program termination problem clr20r3 solution
Are the top ten securities companies at great risk of opening accounts and safe and reliable?
《乔布斯传》英文原著重点词汇笔记(三)【 chapter one】
106. 简易聊天室9:使用 Socket 传递音频
Stimulsoft ultimate presents reports and dashboards
Summary of hardfault problem in RTOS multithreading
cazy長安戰役八卦迷宮
浅谈Mysql底层索引原理
How annotation lib and processor lib reference
Unity--Configurable Joint——简单教程,带你入门可配置关节
[opencv] - input and output XML and yaml files
【期末复习笔记】数字逻辑
Level 6 easy to mix words
RMB 3000 | record "tbtools" video, make a friend and get a cash prize!
Notes on key words in the original English work biography of jobs (II) [chapter one]
atguigu----01-脚手架
Is it safe to open a stock account through the account opening QR code of the account manager? Or is it safe to open an account in a securities company?
Matplotlib decision boundary drawing function plot in Matplotlib_ decision_ Boundary and plt Detailed explanation of contour function
Atguigu---17-life cycle
高速缓冲存储器Cache的映射方式