@echo off
START "app" javaw -jar app-0.0.1-SNAPSHOT.jar
其中的app是你这个bat文件的名字
javaw是jre中的后台启动的文件在jre/bin下
后面的jar文件是启动的jar包
停止jar项目
@echo off
set port=3061
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
上述的方式是直接使用taskkill命令来关闭项目和linux中的kill一样
重启项目
@echo off
set port=3061
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 "app" javaw -jar app-0.0.1-SNAPSHOT.jar