Windows系统编写bat脚本启动,停止,重启Java服务jar包

创建一个以bat后缀结束的文件,写入一下代码:1.启动jar包脚本:在Windows系统上面创建 start.bat 启动jar包脚本编辑以下内容:

创建一个以bat后缀结束的文件,写入一下代码:

1.启动jar包脚本:

在Windows系统上面创建 start.bat 启动jar包脚本编辑以下内容:
给窗口命名:“jeeplus-gateway”,如果是微服务的话方便查看

@echo off
START "jeeplus-gateway" java -jar -Dfile.encoding=utf-8  ./jar/jeeplus-gateway.jar -Dspring.profiles.active=test --server.port=18000 >  ./logs/jeeplus-gateway.log 2>&1 &

2. 停止jar包脚本:

在Windows系统上面创建 stop.bat 停止jar包脚本编辑以下内容:

@echo off
set port=8080
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (
 echo kill the process %%m who use the port 
 taskkill /pid %%m -t -f
 goto q
)
:q

3.重新启动jar包脚本:

重启jar包就是将两个合并到一起:

@echo off
set port=18000
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (
 echo kill the process %%m who use the port 
 taskkill /pid %%m -t -f
 goto start
)
:start
 
START "jeeplus-gateway" java -jar -Dfile.encoding=utf-8  ./jar/jeeplus-gateway.jar -Dspring.profiles.active=test --server.port=18000 >  ./logs/jeeplus-gateway.log 2>&1 &

4.启动脚本:

双击 bat文件 确定窗口启动

发布者:admin,转转请注明出处:http://www.yc00.com/web/1754825280a5204854.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信