Getting Started
Relevant source files
The following files were used as context for generating this wiki page:
The zheng project is a comprehensive, multi-module Java application built using Apache Maven. It follows a distributed, service-oriented architecture, with clear separation of concerns across its various modules. The system is composed of several key subsystems, including User Permission Management (UPMS), Content Management (CMS), Object Storage (OSS), and more, each designed to function as an independent service.
This guide provides a high-level overview of the project's structure, core technologies, and build process. It is intended for developers looking to understand the architecture, set up a development environment, and begin contributing to the project. The system relies heavily on the Spring framework, Dubbo for RPC communication, and MyBatis for data persistence.
Project Structure
The zheng project is organized as a parent Maven project that aggregates numerous sub-modules. This modular design promotes code reusability and independent development and deployment of different services.
Sources: pom.xml:19-32
The following diagram illustrates the high-level module organization defined in the root pom.xml.
Diagram based on the module list in the root POM file.
Sources: pom.xml:19-32
Key Modules
| Module | Description |
|---|---|
zheng-common | Contains common utilities, base classes, and core framework dependencies shared across all other modules. |
zheng-upms | User Permission Management System. Manages users, roles, permissions, and authentication. |
zheng-cms | Content Management System. Handles articles, topics, categories, and other content-related entities. |
zheng-admin | A common administration module, likely providing a base for various admin UIs. |
zheng-oss | Object Storage Service module. |
zheng-pay | Payment processing module. |
zheng-api | Exposes APIs for external or internal clients. |
zheng-message | A messaging service module. |
Sources: pom.xml:19-32
Core Technologies & Dependencies
The zheng-common module centralizes the project's core dependencies, ensuring version consistency across all sub-modules.
Sources: zheng-common/pom.xml
| Dependency | Version | Purpose |
|---|---|---|
spring-framework | 4.3.20.RELEASE | Core application framework for dependency injection, MVC, etc. |
spring-security | 4.2.8.RELEASE | Authentication and access control. |
mybatis | 3.4.2 | Persistence framework for mapping Java objects to SQL. |
mybatis-spring | 1.3.1 | Integrates MyBatis with Spring. |
dubbo | 2.5.6 | A high-performance RPC framework for communication between services. |
shiro | 1.3.2 | Security framework for authentication, authorization, and session management. |
jedis | 2.9.0 | Java client for Redis, used for caching and session management. |
mysql-connector-java | 5.1.34 | JDBC driver for MySQL database. |
druid | 1.0.14 | High-performance JDBC connection pool. |
slf4j | 1.7.12 | Logging facade. |
Sources: zheng-common/pom.xml:17-31, zheng-common/pom.xml:36-248
Module Architecture Example: zheng-cms
To understand the internal structure of a typical module, we can examine zheng-cms. It is further divided into specialized sub-modules, a common pattern in the zheng project.
Sources: zheng-cms/pom.xml:21-30
This diagram shows the sub-modules within zheng-cms.
Diagram illustrating the dependency relationships between zheng-cms sub-modules.
Sources: zheng-cms/pom.xml:21-30, zheng-cms/zheng-cms-admin/pom.xml:19-23
zheng-cms-common: Contains common models and constants for the CMS module.zheng-cms-dao: Data Access Object layer, responsible for database interactions using MyBatis.zheng-cms-rpc-api: Defines the RPC service interfaces (APIs) for the CMS module.zheng-cms-rpc-service: The implementation of the RPC services defined in the API module.zheng-cms-web: The front-facing web application for end-users.zheng-cms-admin: The back-end administration web application.zheng-cms-job: Contains scheduled tasks and jobs related to content management.zheng-cms-search: Provides search functionality for the CMS.
Build and Deployment
The project uses Maven for its build lifecycle. Each web application module (packaging type war) is configured with the jetty-maven-plugin to allow for easy local development and testing.
Sources: zheng-cms/zheng-cms-admin/pom.xml:71-86, zheng-upms/zheng-upms-server/pom.xml:71-86
Maven Profiles
The build is customized for different environments using Maven profiles: dev, test, and prod. The dev profile is active by default. These profiles control which properties file is used to filter resources, allowing for environment-specific configurations (e.g., database connections, server ports).
<profiles>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<env>test</env>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<env>prod</env>
</properties>
</profile>
</profiles>
Source: zheng-cms/zheng-cms-admin/pom.xml:36-58
Running Services Locally
Each web application can be started by running the Jetty plugin. The table below lists some of the services and their default HTTP ports configured for local development.
| Service Module | Default Port | Command |
|---|---|---|
zheng-upms-server | 1111 | mvn -pl zheng-upms/zheng-upms-server jetty:run |
zheng-cms-admin | 2222 | mvn -pl zheng-cms/zheng-cms-admin jetty:run |
zheng-cms-job | 2223 | mvn -pl zheng-cms/zheng-cms-job jetty:run |
zheng-cms-web | 2224 | mvn -pl zheng-cms/zheng-cms-web jetty:run |
zheng-api-server | 6666 | mvn -pl zheng-api/zheng-api-server jetty:run |
zheng-oss-admin | 7772 | mvn -pl zheng-oss/zheng-oss-admin jetty:run |
Sources: zheng-upms/zheng-upms-server/pom.xml:83, zheng-cms/zheng-cms-admin/pom.xml:83, zheng-cms/zheng-cms-job/pom.xml:83, zheng-cms/zheng-cms-web/pom.xml:86, zheng-api/zheng-api-server/pom.xml:83, zheng-oss/zheng-oss-admin/pom.xml:83
Data Persistence and Code Generation
Modules like zheng-upms-dao and zheng-cms-dao use the mybatis-generator-maven-plugin to automatically generate model classes, mappers, and XML mapping files from the database schema. This streamlines the development of the data access layer.
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<dependencies>
<dependency>
<groupId>com.zheng</groupId>
<artifactId>zheng-common</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>