新大洲车联网 CRM 系统服务端,基于 Spring Boot 3.5.9 构建的微服务架构。
xdz_server/
├── xdz-dependencies/ # 依赖管理模块
├── xdz-framework/ # 框架基础模块
├── xdz-module-user/ # 用户服务模块
│ ├── xdz-module-user-api/ # 用户服务 API(供其他服务调用)
│ └── xdz-module-user-server/ # 用户服务(端口:18080)
├── xdz-module-vehicle/ # 车辆服务模块
│ ├── xdz-module-vehicle-api/ # 车辆服务 API(供其他服务调用)
│ └── xdz-module-vehicle-server/ # 车辆服务(端口:18083)
├── xdz-module-message/ # 消息服务模块
│ ├── xdz-module-message-api/ # 消息服务 API(供其他服务调用)
│ └── xdz-module-message-server/ # 消息服务(端口:18082)
├── xdz-module-business/ # 业务服务模块
│ ├── xdz-module-business-api/ # 业务服务 API(供其他服务调用)
│ └── xdz-module-business-server/ # 业务服务(端口:18081)
│ └── 包含社区模块(社区功能已集成到业务服务中)
└── xdz-module-platform/ # 平台服务模块(预留)
xdz-dependencies (依赖管理)
↓
xdz-framework (框架基础,依赖 xdz-dependencies)
↓
├── API 模块(可并行编译,无相互依赖)
│ ├── xdz-module-user-api
│ ├── xdz-module-vehicle-api
│ ├── xdz-module-message-api
│ └── xdz-module-business-api
│
└── Server 模块(依赖对应的 API 模块)
├── xdz-module-user-server
│ └── 依赖:user-api, business-api
│
├── xdz-module-vehicle-server
│ └── 依赖:vehicle-api, user-api, message-api
│
├── xdz-module-message-server
│ └── 依赖:message-api, vehicle-api
│
└── xdz-module-business-server
└── 依赖:business-api, vehicle-api, message-api, user-api
编译顺序说明:
xdz-dependencies → xdz-frameworkuser-server 需要 user-api 和 business-apivehicle-server 需要 vehicle-api、user-api、message-apimessage-server 需要 message-api 和 vehicle-apibusiness-server 需要所有 API 模块用户服务 (18080)
业务服务 (18081)
车辆服务 (18083)
消息服务 (18082)
确保 MySQL 服务已启动,并创建相应的数据库。
# 启动 Redis(默认端口 6379)
redis-server
根据各服务的 application-local.yaml 配置文件,修改数据库连接信息:
xdz_userxdz_vehiclexdz_messagexdz_business(包含社区模块的表)
xdz_business 数据库中community_ 开头(如 community_post、community_comment 等)重要:首次启动前,必须先编译整个项目。Maven 会按照模块依赖顺序自动编译。
由于模块之间存在依赖关系,必须按照以下顺序编译:
# 进入项目根目录
cd xdz_server
# 编译整个项目(Maven 会自动处理依赖顺序)
# 注意:使用 -DskipTests 跳过测试(测试代码已忽略,不提交到 Git)
mvn clean install -DskipTests
说明:
-DskipTests 跳过测试阶段(测试代码不提交到 Git,本地也没有测试代码)-DskipTests 参数# 注意:所有命令都添加了 -DskipTests 参数跳过测试
# 1. 先编译依赖管理模块
mvn clean install -pl xdz-dependencies -am -DskipTests
# 2. 编译框架模块(依赖 xdz-dependencies)
mvn clean install -pl xdz-framework -am -DskipTests
# 3. 编译所有 API 模块(可并行,无相互依赖)
mvn clean install -pl xdz-module-user/xdz-module-user-api -am -DskipTests
mvn clean install -pl xdz-module-vehicle/xdz-module-vehicle-api -am -DskipTests
mvn clean install -pl xdz-module-message/xdz-module-message-api -am -DskipTests
mvn clean install -pl xdz-module-business/xdz-module-business-api -am -DskipTests
# 4. 编译用户服务(依赖 user-api, business-api)
mvn clean install -pl xdz-module-user -am -DskipTests
# 5. 编译车辆服务(依赖 vehicle-api, user-api, message-api)
mvn clean install -pl xdz-module-vehicle -am -DskipTests
# 6. 编译消息服务(依赖 message-api, vehicle-api)
mvn clean install -pl xdz-module-message -am -DskipTests
# 7. 编译业务服务(依赖所有 API 模块)
mvn clean install -pl xdz-module-business -am -DskipTests
注意:
user-api,需要重新编译 xdz-module-user-api,然后重新编译 xdz-module-user-server 和 xdz-module-business-server前提:确保已完成步骤 3 的编译。
启动用户服务:
# 在项目根目录执行
cd xdz-module-user/xdz-module-user-server
mvn spring-boot:run -Dspring-boot.run.profiles=local -DskipTests
启动业务服务:
cd xdz-module-business/xdz-module-business-server
mvn spring-boot:run -Dspring-boot.run.profiles=local -DskipTests
启动车辆服务:
cd xdz-module-vehicle/xdz-module-vehicle-server
mvn spring-boot:run -Dspring-boot.run.profiles=local -DskipTests
启动消息服务:
cd xdz-module-message/xdz-module-message-server
mvn spring-boot:run -Dspring-boot.run.profiles=local -DskipTests
说明:
mvn spring-boot:run 时,Maven 会自动编译依赖的模块mvn clean install -DskipTests-DskipTests 参数跳过测试(测试代码不提交到 Git)UserServerApplication - 用户服务BusinessServerApplication - 业务服务VehicleServerApplication - 车辆服务MessageServiceApplication - 消息服务Run,并设置 Active profiles 为 local重要:由于服务间存在依赖关系,必须按照以下顺序启动:
用户服务(18080)
业务服务(18081)
车辆服务(18083)
消息服务(18082)
用户服务 和 业务服务 存在相互依赖:
车辆服务 依赖用户服务 API 和消息服务 API:
消息服务 依赖车辆服务 API:
业务服务 包含社区模块,社区功能通过业务服务访问(端口 18081)
| 服务 | 端口 | 说明 |
|---|---|---|
| 用户服务 | 18080 | 用户认证、会员管理、C端用户管理 |
| 业务服务 | 18081 | 系统管理、权限管理、社区模块(帖子、评论、话题、敏感词等) |
| 消息服务 | 18082 | SocketIO 实时通信 |
| 车辆服务 | 18083 | 车辆管理、车辆控制 |
| SocketIO | 9090 | WebSocket 实时通信端口 |
注意:社区模块已集成到业务服务中,通过业务服务的端口(18081)访问,路径为 /admin-api/community/*。
http://localhost:18080http://localhost:18081http://localhost:18083http://localhost:18082各服务的日志会输出到控制台,启动成功后会看到类似信息:
Started UserServerApplication in X.XXX seconds
Started BusinessServerApplication in X.XXX seconds
Started VehicleServerApplication in X.XXX seconds
Started MessageServiceApplication in X.XXX seconds
各服务之间通过 Feign 调用时,会自动生成服务间 JWT Token 进行认证。
需要私钥的服务(需要调用其他服务):
只需公钥的服务(只被调用):
各服务的密钥文件位于:
xdz-module-{service}-server/src/main/resources/jwt/
├── service_jwt_private_key.pem # 私钥(用于生成 Token)
└── service_jwt_public_key.pem # 公钥(用于验证 Token)
解决方案:
mvn clean install -pl xdz-dependencies -am
解决方案:修改 application.yaml 中的 server.port 配置
解决方案:检查 application-local.yaml 中的数据库配置:
解决方案:
application-local.yaml 中的 Redis 配置解决方案:
解决方案:
/admin-api/community/*xdz_business 数据库中)CommunityPostMapper、CommunityTopicMapper 等)各服务的配置文件位于:
xdz-module-{service}-server/src/main/resources/
├── application.yaml # 主配置文件
├── application-local.yaml # 本地开发环境配置
├── application-dev.yaml # 开发环境配置
└── application-prod.yaml # 生产环境配置
启动时使用 local profile,会加载 application.yaml 和 application-local.yaml。
如有问题,请联系开发团队。