From 93323766db322ba75977ba62191f302a256f70f1 Mon Sep 17 00:00:00 2001 From: yun-zhi-ztl <15071461069@163.com> Date: Mon, 16 Mar 2026 12:16:01 +0800 Subject: [PATCH] fix: stabilize backend dev module classpath --- Makefile | 8 +++++--- docs/dev-workflow.md | 5 +++-- scripts/check-openapi-generated.sh | 2 +- server/skillhub-app/pom.xml | 9 +++++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f8e6f012..70e1789a 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,8 @@ STAGING_API_URL := http://localhost:8080 STAGING_WEB_URL := http://localhost STAGING_SERVER_IMAGE := skillhub-server:staging DEV_PROCESS := python3 scripts/dev_process.py +DEV_SERVER_PREPARE := ./mvnw -pl skillhub-app -am compile -DskipTests >/dev/null +DEV_SERVER_CMD := ./mvnw -pl skillhub-app spring-boot:run -Dspring-boot.run.profiles=local PARALLEL_BASE_REF ?= origin/main PARALLEL_WORKTREE_ROOT ?= DEV_COMPOSE_PROJECT_NAME ?= skillhub @@ -40,7 +42,7 @@ dev-all: ## 一键启动本地开发环境(依赖 + 后端 + 前端) echo "Backend already running with PID $$(cat $(DEV_SERVER_PID))"; \ else \ echo "Starting backend..."; \ - $(DEV_PROCESS) start --pid-file $(DEV_SERVER_PID) --log-file $(DEV_SERVER_LOG) --cwd server -- /bin/sh -lc './mvnw -pl skillhub-app -am install -DskipTests >/dev/null && exec ./mvnw -pl skillhub-app spring-boot:run -Dspring-boot.run.profiles=local' >/dev/null; \ + $(DEV_PROCESS) start --pid-file $(DEV_SERVER_PID) --log-file $(DEV_SERVER_LOG) --cwd server -- /bin/sh -lc '$(DEV_SERVER_PREPARE) && exec $(DEV_SERVER_CMD)' >/dev/null; \ fi @if $(DEV_PROCESS) status --pid-file $(DEV_WEB_PID) >/dev/null 2>&1; then \ echo "Frontend already running with PID $$(cat $(DEV_WEB_PID))"; \ @@ -66,7 +68,7 @@ dev-all: ## 一键启动本地开发环境(依赖 + 后端 + 前端) echo "Backend did not become ready on attempt $$attempt. Restarting..."; \ $(DEV_PROCESS) stop --pid-file $(DEV_SERVER_PID); \ sleep 2; \ - $(DEV_PROCESS) start --pid-file $(DEV_SERVER_PID) --log-file $(DEV_SERVER_LOG) --cwd server -- /bin/sh -lc './mvnw -pl skillhub-app -am install -DskipTests >/dev/null && exec ./mvnw -pl skillhub-app spring-boot:run -Dspring-boot.run.profiles=local' >/dev/null; \ + $(DEV_PROCESS) start --pid-file $(DEV_SERVER_PID) --log-file $(DEV_SERVER_LOG) --cwd server -- /bin/sh -lc '$(DEV_SERVER_PREPARE) && exec $(DEV_SERVER_CMD)' >/dev/null; \ fi; \ done; \ if [ "$$backend_ready" -ne 1 ]; then \ @@ -98,7 +100,7 @@ dev-all: ## 一键启动本地开发环境(依赖 + 后端 + 前端) @echo " Frontend: $(DEV_WEB_LOG)" dev-server: ## 启动后端开发服务器 - cd server && /bin/sh -lc './mvnw -pl skillhub-app -am install -DskipTests >/dev/null && exec ./mvnw -pl skillhub-app spring-boot:run -Dspring-boot.run.profiles=local' + cd server && /bin/sh -lc '$(DEV_SERVER_PREPARE) && exec $(DEV_SERVER_CMD)' dev-down: ## 停止本地开发环境 $(DEV_COMPOSE) down --remove-orphans diff --git a/docs/dev-workflow.md b/docs/dev-workflow.md index d982dc44..9878517a 100644 --- a/docs/dev-workflow.md +++ b/docs/dev-workflow.md @@ -32,8 +32,9 @@ SkillHub now pins a shared Docker Compose project name for local development, so **Backend:** Spring Boot DevTools is configured. After editing Java code: 1. In IntelliJ IDEA: press `Cmd+F9` (Build Project) -2. The backend restarts automatically in 3-8 seconds -3. Watch the terminal running `make dev-server` for the restart log +2. If you changed code in another backend module such as `skillhub-domain` or `skillhub-search`, make sure the whole server project is rebuilt, not just `skillhub-app` +3. The backend restarts automatically in 3-8 seconds +4. Watch the terminal running `make dev-server` for the restart log ### Mock authentication diff --git a/scripts/check-openapi-generated.sh b/scripts/check-openapi-generated.sh index c111ab0f..9a9f79f8 100755 --- a/scripts/check-openapi-generated.sh +++ b/scripts/check-openapi-generated.sh @@ -34,7 +34,7 @@ docker compose up -d --wait postgres redis ( cd "$SERVER_DIR" - ./mvnw -pl skillhub-app -am -DskipTests install + ./mvnw -pl skillhub-app -am compile -DskipTests ) >"$BUILD_LOG" 2>&1 || { echo "Failed to prepare backend modules. See $BUILD_LOG" >&2 print_log_tail "$BUILD_LOG" diff --git a/server/skillhub-app/pom.xml b/server/skillhub-app/pom.xml index f7ddf6ca..377e1616 100644 --- a/server/skillhub-app/pom.xml +++ b/server/skillhub-app/pom.xml @@ -101,6 +101,15 @@ org.springframework.boot spring-boot-maven-plugin + + + ${project.parent.basedir}/skillhub-domain/target/classes + ${project.parent.basedir}/skillhub-auth/target/classes + ${project.parent.basedir}/skillhub-infra/target/classes + ${project.parent.basedir}/skillhub-search/target/classes + ${project.parent.basedir}/skillhub-storage/target/classes + +