fix: stabilize backend dev module classpath

This commit is contained in:
yun-zhi-ztl 2026-03-16 12:16:01 +08:00 committed by Xudong Sun
parent f92cdb31f2
commit 93323766db
4 changed files with 18 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -101,6 +101,15 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${project.parent.basedir}/skillhub-domain/target/classes</additionalClasspathElement>
<additionalClasspathElement>${project.parent.basedir}/skillhub-auth/target/classes</additionalClasspathElement>
<additionalClasspathElement>${project.parent.basedir}/skillhub-infra/target/classes</additionalClasspathElement>
<additionalClasspathElement>${project.parent.basedir}/skillhub-search/target/classes</additionalClasspathElement>
<additionalClasspathElement>${project.parent.basedir}/skillhub-storage/target/classes</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>
</build>