-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_start.bat
More file actions
75 lines (64 loc) · 1.96 KB
/
Copy pathquick_start.bat
File metadata and controls
75 lines (64 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@echo off
chcp 65001 >nul 2>&1
title Campus Vehicle Management System
cd /d "%~dp0"
set "MVN=%~dp0.tools\apache-maven-3.9.9\bin\mvn.cmd"
set "APP_URL=http://localhost:8080"
if "%~1"=="--open-browser" goto waitAndOpen
if not defined JAVA_HOME (
if exist "%~dp0.tools\jdk-17\bin\java.exe" set "JAVA_HOME=%~dp0.tools\jdk-17"
)
if not defined JAVA_HOME (
if exist "C:\Program Files\Java\jdk-21\bin\java.exe" set "JAVA_HOME=C:\Program Files\Java\jdk-21"
)
if not defined JAVA_HOME (
if exist "C:\Program Files\Java\jdk-17\bin\java.exe" set "JAVA_HOME=C:\Program Files\Java\jdk-17"
)
if defined JAVA_HOME set "PATH=%JAVA_HOME%\bin;%PATH%"
echo ========================================
echo Campus Vehicle Management System
echo ========================================
echo.
if not exist "%MVN%" (
echo Local Maven not found: %MVN%
echo Please make sure .tools\apache-maven-3.9.9 exists.
pause
exit /b 1
)
where java >nul 2>&1
if errorlevel 1 (
echo JDK not found. Please install JDK 17+ or set JAVA_HOME.
pause
exit /b 1
)
echo [1/3] Checking port 8080...
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":8080" ^| findstr "LISTENING"') do (
echo Port 8080 is used by process %%a, stopping it...
taskkill /F /PID %%a >nul 2>&1
echo Stopped process %%a
)
echo Port 8080 is ready.
echo.
echo [2/3] Starting Spring Boot application...
echo.
start "Open Browser" /min cmd /c call "%~f0" --open-browser
echo Waiting for startup. Browser will open automatically: %APP_URL%
call "%MVN%" spring-boot:run
echo.
echo Application stopped.
pause
exit /b 0
:waitAndOpen
echo Waiting for service startup...
for /l %%i in (1,1,90) do (
netstat -ano | findstr ":8080" | findstr "LISTENING" >nul
if not errorlevel 1 (
ping -n 3 127.0.0.1 >nul
echo Service is ready. Opening browser...
start "" "%APP_URL%"
exit /b 0
)
ping -n 3 127.0.0.1 >nul
)
echo Timed out waiting for startup. Open %APP_URL% manually.
exit /b 1