# (mac 使用sh建立腳本啟動vue+spring) ### Step 1: 新增選取sh檔 - [x] Create first sh runShell.sh ```shell echo "-------------------------start-----------------------------" echo "請選擇要啟動的項目" #自行新增要對應的項目 echo "前端---1" echo "後端---2" echo "請輸入:" read targetName sleep 0.5 scheme_name="$targetName" echo "選擇的項目: ${scheme_name} " if [ -n "$targetName" ] then if [ "$targetName" = "1" ] ; then #更換自己要的路徑 cd /輸入自己電腦路徑/folder ./RunVue.sh elif [ "$targetName" = "2" ] ; then #更換自己要的路徑 cd /輸入自己電腦路徑/folder ./RunSpringBoot.sh else echo "無效參數: ${scheme_name} " exit 1 fi fi ``` ### Step 2: 新增vue的sh檔 - [x] Create mapping targetName = 1 second sh RunVue.sh ``` #先判斷執行目錄有無檔案 #無檔案透過node 執行打包專案 #若有檔案 直接執行node_modules if [ -f "輸入自己電腦路徑/node_modules" ]; then # 目錄存在 echo "執行專案 "; sleep 1 #切到對應啟動的vue資料夾下後執行 cd /輸入自己電腦路徑/vue npm run serve else # 目錄不存在 echo "Does not exists." echo "執行打包專案 "; cd 輸入自己專案項目打包路徑 npm ci sleep 3 echo "執行專案 "; npm run serve fi ``` ### Step 3: 新增springboot的sh檔 - [x] Create mapping targetName = 2 third sh RunSpringBoot.sh ``` #先判斷執行目錄有無檔案 #無檔案透過maven 執行打包專案 #若有檔案 直接執行jar包 if [ -f "輸入自己電腦路徑/target/first_spring-0.0.1-SNAPSHOT.jar" ]; then # 目錄存在 echo "執行專案 "; sleep 1 java -jar /輸入自己電腦路徑/target/first_spring-0.0.1-SNAPSHOT.jar else # 目錄不存在 echo "Does not exists." echo "執行打包專案 "; cd 輸入自己專案項目打包路徑 mvn package sleep 3 echo "執行專案 "; java -jar /輸入自己電腦路徑/target/first_spring-0.0.1-SNAPSHOT.jar fi ``` ### Step 4: 中斷/停止程序 - [x] use command+C in your cmd ###### tags: `操作筆記`