run.bat 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. @echo off
  2. chcp 65001 >nul
  3. setlocal EnableDelayedExpansion
  4. set "FRONTEND_DIR=frontend"
  5. set "BACKEND_DIR=backend"
  6. echo ========================================
  7. echo 知识库管理系统 - 合并构建部署工具
  8. echo ========================================
  9. echo.
  10. if "%~1"=="build" (
  11. echo [模式] 仅构建(不启动服务)
  12. call :build
  13. echo.
  14. echo [完成] 构建成功!使用 java -jar %BACKEND_DIR%\target\knowledge-extractor.jar 运行
  15. goto :eof
  16. )
  17. if "%~1"=="" (
  18. echo [模式] 构建 + 启动
  19. call :build
  20. echo.
  21. echo [启动] 正在启动后端服务(端口 7945)...
  22. cd %BACKEND_DIR%
  23. mvn spring-boot:run -q
  24. goto :eof
  25. )
  26. if "%~1"=="db" (
  27. echo [模式] 初始化数据库(执行 schema.sql)
  28. echo 请确认 application.yml 中的数据库连接信息
  29. cd %BACKEND_DIR%
  30. mvn -q exec:java -Dexec.mainClass="com.knowledge.extractor.KnowledgeExtractorApplication" -Dexec.args="--init-db"
  31. goto :eof
  32. )
  33. echo [用法]
  34. echo run.bat 构建 + 运行(端口 7945)
  35. echo run.bat build 仅构建
  36. goto :eof
  37. :build
  38. echo ---- [1/2] 前端打包(直接输出到后端 static 目录)----
  39. cd %FRONTEND_DIR%
  40. call npm run build
  41. if errorlevel 1 (
  42. echo [错误] 前端打包失败!
  43. exit /b 1
  44. )
  45. cd ..
  46. echo ---- [2/2] 后端打包 ----
  47. cd %BACKEND_DIR%
  48. call mvn package -DskipTests -q
  49. if errorlevel 1 (
  50. echo [错误] 后端打包失败!
  51. cd ..
  52. exit /b 1
  53. )
  54. cd ..
  55. echo ---- 构建完成 ----
  56. goto :eof