How zhaopei0418/springboot works
1. This repository is a single Spring Boot application that acts as a small integration/demo platform. It combines REST APIs, two MyBatis-backed databases, Redis pub/sub, RabbitMQ messaging, and a bit of Spring Integration/Jersey support in one deployable service.
2. The application entry point is Application.java, and the project is built with Maven (pom.xml). The app runs as an embedded server on port 8081 via mvn spring-boot:run, so the whole architecture is packaged and started as one process.
3. The primary HTTP API layer lives under controller/. These Spring MVC controllers expose the main endpoints for cities, users, Redis publishing, and queue actions. The README confirms a simple root/home response and a Redis publish test endpoint at /redis/publish.
4. There is also a Jersey-based REST layer in jerseyservice/ and resource/, wired by config/JerseyConfig.java. That means the repo supports two REST styles side by side: Spring MVC controllers and JAX-RS resources.
5. Persistence is split across two databases. PrimaryDatabaseConfiguration.java and SecondDatabaseConfig.java set up separate MyBatis data sources, with mapper packages divided into mapper/primary and mapper/second. This is an important architectural boundary: City data is isolated from UserTest data.
6. The domain/model layer is very small and purpose-built. domain/City.java and domain/UserTest.java map to the two persistence areas. Service interfaces and implementations (service/, service/impl/) sit between controllers and mappers, so controllers do not talk to MyBatis directly.
7. SQL is organized with provider classes in sqlprovide/ rather than only static XML mappers. CitySqlProvide.java and UserTestProvide.java indicate dynamic SQL generation for at least part of the persistence layer.
8. Redis is used for publish/subscribe messaging. RedisConfigation.java configures the Redis client and IntegrationConfiguration.java appears to wire the subscription side. The README shows the main flow: an HTTP call publishes a message, and the app logs the received subscription message.
9. RabbitMQ is the second messaging path. RabbitMQConfigration.java, service/Sender.java, service/Receiver.java, and controller/QueueController.java together form a queue example. The README also highlights broker credentials in application.yml, so RabbitMQ is an external runtime dependency, not an in-memory demo.
10. Spring Integration is present as an integration boundary, not just plain messaging. src/main/resources/application-integration-redis.xml and config/spring-integration-file-context.xml, plus classes like QueueReadingMessageSource and DefaultFileNameGenerator, suggest file/message flow examples wired through Spring Integration channels and adapters.
11. The repo includes some API documentation assets under src/main/resources/static/apidocs/. The README points to /apidocs/index.html, so Swagger-style documentation is served as static content from the application itself.
12. There are utility and test-only pieces that are not part of the main request flow. util/QRCodeUtil.java is a standalone helper with a corresponding unit test, and CXFClientTest.java suggests a client/integration test for an external service style endpoint.
13. Architecturally, the application boundary is: HTTP requests enter through Spring MVC or Jersey, business logic runs in service classes, data access goes through MyBatis to one of two databases, and asynchronous/integration flows go out through Redis or RabbitMQ. External services are Redis, RabbitMQ, and the configured relational databases.
14. If you draw this repo, the main diagram should show one Spring Boot monolith with three notable subsystems beneath it: REST/API delivery, dual-database persistence, and messaging/integration. The strongest repo-specific detail is that these subsystems are intentionally demonstrated in parallel rather than abstracted behind a single unified infrastructure layer.
Main entry points: controller Spring APIs · Application.java Application · JerseyConfig.java Jersey Config · CityServiceImpl.java City Service
Components 16
Boot app
Single Spring Boot deployable runtime and entry point.
- Application · Spring Boot launcher and embedded server entry point.
src/main/java/online/zhaopei/myproject/Application.java
API layer
HTTP delivery through Spring MVC and Jersey.
- Spring APIs · Primary REST endpoints for cities, users, Redis publishing, and queue actions.
src/main/java/online/zhaopei/myproject/controller - Jersey Config · Wires the Jersey REST layer into the application.
src/main/java/online/zhaopei/myproject/config/JerseyConfig.java - Jersey APIs · JAX-RS endpoints exposed alongside Spring MVC.
src/main/java/online/zhaopei/myproject/resource - API Docs · Swagger-style documentation served from static resources.
src/main/resources/static/apidocs/index.html
Persistence
Dual MyBatis-backed database access.
- Primary DB · Primary datasource and MyBatis setup for city data.
src/main/java/online/zhaopei/myproject/config/PrimaryDatabaseConfiguration.java - Second DB · Secondary datasource and MyBatis setup for user data.
src/main/java/online/zhaopei/myproject/config/SecondDatabaseConfig.java - City Service · Business layer for city operations.
src/main/java/online/zhaopei/myproject/service/impl/CityServiceImpl.java - User Service · Business layer for user-test operations.
src/main/java/online/zhaopei/myproject/service/impl/UserTestServiceImpl.java - City Mapper · Primary database mapper for city persistence.
src/main/java/online/zhaopei/myproject/mapper/primary/CityMapper.java - User Mapper · Secondary database mapper for user-test persistence.
src/main/java/online/zhaopei/myproject/mapper/second/UserTestMapper.java
Messaging
Redis, RabbitMQ, and Spring Integration flows.
- Redis Config · Redis client and publish/subscribe setup.
src/main/java/online/zhaopei/myproject/config/RedisConfigation.java - Redis Integration · Spring Integration wiring for Redis subscription handling.
src/main/java/online/zhaopei/myproject/config/IntegrationConfiguration.java - RabbitMQ Config · RabbitMQ broker and queue configuration.
src/main/java/online/zhaopei/myproject/config/RabbitMQConfigration.java - Queue Flow · Sender and receiver pair for RabbitMQ messaging.
src/main/java/online/zhaopei/myproject/service - Integration Flow · File and message-flow support via Spring Integration resources and helpers.
src/main/resources/application-integration-redis.xml
Connections 15
- Application → Spring APIs: starts · Boot application exposes the Spring MVC API layer.
- Application → Jersey Config: enables · Boot application loads the Jersey REST configuration.
- Jersey Config → Jersey APIs: registers · Jersey configuration binds JAX-RS resources.
- Spring APIs → City Service: uses · City endpoints delegate to the city service.
- Spring APIs → User Service: uses · User endpoints delegate to the user service.
- City Service → City Mapper: persists · City service reads and writes through the primary mapper.
- User Service → User Mapper: persists · User service reads and writes through the secondary mapper.
- City Mapper → Primary DB: binds to · City mapper is attached to the primary datasource.
- User Mapper → Second DB: binds to · User mapper is attached to the secondary datasource.
- Spring APIs → Redis Config: publishes · Redis publish endpoint sends messages through the Redis setup.
- Redis Config → Redis Integration: subscribes · Integration config handles Redis subscription flow.
- Spring APIs → RabbitMQ Config: triggers · Queue-related controller actions go through RabbitMQ setup.
- RabbitMQ Config → Queue Flow: wires · RabbitMQ configuration supports sender/receiver messaging.
- Integration Flow → Queue Flow: adapts · Spring Integration resources participate in message/file flow examples.
- Application → API Docs: serves · Application exposes static API documentation assets.