This system is built using the SSM (Spring, Spring MVC, MyBatis) framework for the backend, JSP for the frontend, and MySQL as the database.
Core Technology Stack
Backend: Spring Framework
Spring provides comprehensive infrastructure support for Java development, handling dependency injection and aspect-oriented programming. Spring MVC serves as the request-driven web framework, managing the flow between controllers, models, and views.
Data Persistence: MyBatis
MyBatis is a lightweight persistence framework that simplifies database interactions by mapping Java objects to SQL statements via XML or annotations, offering fine-grained control over SQL execution.
Frontend: JSP (JavaServer Pages)
JSP technology enables the creation of dynamic web content by embedding Java code within HTML pages, which are compiled into servlets on the server.
Database: MySQL
MySQL is the chosen relational database management system for storing application data, known for its reliability and performance.
Key Code Examples
The following configuration snippet shows the core setup for data source and MyBatis-Plus integration within the application.yml file.
server:
tomcat:
uri-encoding: UTF-8
port: 8080
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/academic_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
username: app_user
password: secure_pass
mybatis-plus:
mapper-locations: classpath:mapper/**/*.xml
type-aliases-package: com.example.entity
global-config:
db-config:
id-type: AUTO
logic-delete-field: deleted
logic-delete-value: 1
logic-not-delete-value: 0
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
Below is a sample MyBatis XML mapper file for a Staff entity, demonstrating result mapping and a dynamic query.
<?xml version="1.0" encoding="UTF-8"?>
<mapper namespace="com.example.dao.StaffDao">
<resultMap id="staffResultMap" type="com.example.entity.Staff">
<result property="employeeId" column="employee_id"/>
<result property="name" column="staff_name"/>
<result property="position" column="position"/>
<result property="department" column="department"/>
<result property="hireDate" column="hire_date"/>
</resultMap>
<select id="selectByCondition" resultMap="staffResultMap">
SELECT * FROM staff
<where>
<if test="dept != null">
AND department = #{dept}
</if>
<if test="pos != null">
AND position = #{pos}
</if>
</where>
</select>
</mapper>
System Architecture Overview
The application follows a layered architecture:
- Presentation Layer: JSP pages handle user interface rendering and request reception.
- Controller Layer: Spring MVC controllers process HTTP requests, invoke business logic, and return model data to the view.
- Service Layer: Spring-managed services contain the core business rules and transactional operations.
- DAO Layer: MyBatis mappers interact with the MySQL databace to perform CRUD operations.
- Domain Layer: Plain Old Java Objects (POJOs) represent the core data entities like
User,Achievement, andProject.
The configuration centralizes settings for the web server, database connection, and ORM framework, promoting maintainability.