windows下启停jar并指定application.yml配置文件

启动脚本

start.bat

@echo off
REM 设置jar文件名和application.yml文件名
set JAR_FILE=xxx-boot.jar
set YML_FILE=application-prod.yml
set ACTIVE=prod
set PORT=8080

REM 启动jar
:start
java -jar %JAR_FILE% --server.port=%PORT% --spring.profiles.active=%ACTIVE% --spring.config.location=%YML_FILE%

goto :end

停止脚本

close.bat

@echo off
setlocal
set JAR_NAME=xxx-boot.jar
 
for /f "tokens=1" %%a in ('jps -l ^| findstr /R /C:"%JAR_NAME%"') do (
    echo 正在关闭Java应用程序,进程ID为 %%a ...
    taskkill /F /PID %%a
)
 
endlocal
echo 完成.
posted @ 2024-03-20 11:35  土木转行的人才  阅读(256)  评论(0编辑  收藏  举报