# (windows 使用bat建立腳本啟動vue+spring) ### Step 1: 新增選取bat檔 - [x] Create first bat runShell.bat ```shell @echo off cd /d F:\MY_WEB\start_web :label echo "-------------------------start-----------------------------" echo "請選擇要啟動的項目" echo "前端<Vue> --->> 1" echo "後端<springBoot> --->> 2" echo "離開選單 --->> 3" echo 請輸入你要執行的項目: set /p var=PleaseEnterVar: echo 準備啟動 %var% if %var% == 1 ( start cmd /k call RunVue.bat goto label ) if %var% == 2 ( start cmd /k call RunSpringBoot.bat goto label ) if %var% == 3 ( pause ) ``` ### Step 2: 新增vue的bat檔 - [x] Create mapping targetName = 1 second bat RunVue.bat ``` #先判斷執行目錄有無檔案 #無檔案透過node 執行打包專案 #若有檔案 直接執行node_modules @echo off SET SourcePath=F:\MY_WEB\vue2 SET SourceFile=%SourcePath%\node_modules cd /d %SourcePath% if exist %SourceFile% ( npm run serve ) else ( npm ci npm run serve ) ``` ### Step 3: 新增springboot的bat檔 - [x] Create mapping targetName = 2 third bat RunSpringBoot.bat ``` #先判斷執行目錄有無檔案 #無檔案透過maven 執行打包專案 #若有檔案 直接執行jar包 @echo off SET SourcePath=F:\MY_WEB\springboot SET SourceFile=%SourcePath%\target\spring_vue-0.0.1-SNAPSHOT.jar cd /d %SourcePath% if exist %SourceFile% ( java -jar %SourceFile% ) else ( mvn package java -jar %SourceFile% ) fi ``` ### Step 4: 中斷/停止程序 - [x] use command+C in your cmd ###### tags: `操作筆記`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up