# task2 **Repository Path**: yxlzp/task2 ## Basic Information - **Project Name**: task2 - **Description**: # 学生选课系统 This is a project repository for 学生选课系统. ## Description This repository contains the code and resources for 学生选课系统. ## Getting Started To get started with this project, clone the reposi - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: druid-demo - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-03-16 - **Last Updated**: 2026-08-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 学生选课系统 (Student Course Selection System) ## 1. 项目简介 本项目是一个基于 Spring Boot 3 的轻量级学生选课系统。它展示了现代 Java Web 开发的核心技术栈,包括 RESTful API 设计、MyBatis-Plus 持久层操作、Spring Security 与 JWT 结合的无状态认证机制,以及 Druid 高性能数据库连接池的集成。 ## 2. 技术栈 ### 后端 - **核心框架**: Spring Boot 3.1.5 - **安全框架**: Spring Security (基于 JWT 的无状态认证) - **持久层**: MyBatis-Plus 3.5.3.1 - **数据库**: H2 嵌入式数据库 (内存模式,无需安装) - **连接池**: Alibaba Druid 1.2.20 (集成监控面板) - **工具库**: Lombok, JJWT, Commons Codec ### 前端 - **样式框架**: Bootstrap 5 - **交互逻辑**: 原生 JavaScript (ES6+) - **认证方式**: JWT 令牌存储于 LocalStorage,并通过请求头携带 ## 3. 核心功能 - **学生管理**: 实现学生信息的增删改查。 - **课程管理**: 实现课程信息的增删改查。 - **选课管理**: - 学生只能为自己选课(基于 JWT 权限校验)。 - 一个学生只能选择一门课程。 - 支持查看所有学生的选课详情。 - **安全认证**: - 用户名/密码登录(密码 MD5 加密)。 - 登录成功颁发 JWT 令牌(1小时有效期)。 - 接口访问受 Spring Security 保护。 - **监控功能**: - Druid SQL 监控面板 (`/druid`)。 - H2 数据库控制台 (`/h2-console`)。 ## 4. 快速启动 ### 环境要求 - JDK 17+ - Maven 3.6+ ### 运行步骤 1. 克隆仓库: ```bash git clone ``` 2. 进入项目目录并运行: ```bash mvn spring-boot:run ``` 3. 访问系统: 打开浏览器访问 [http://localhost:8080/login.html](http://localhost:8080/login.html) ### 默认测试账号 系统启动时会自动初始化以下测试数据: - **用户名**: 张三 / 李四 / 王五 (对应初始化的学生姓名) - **密码**: `123456` ## 5. 项目结构 ```text src/main/java/com/example/studentcourse/ ├── config/ # Spring Security, MyBatis-Plus 配置 ├── controller/ # RESTful API 控制器 ├── init/ # 系统启动初始化逻辑 ├── mapper/ # MyBatis Mapper 接口 ├── model/ # 实体类 (User, Student, Course, Enrollment) ├── security/ # JWT 过滤器及工具类 └── service/ # 业务逻辑实现 ``` ## 6. 监控入口 - **Druid 监控**: [http://localhost:8080/druid](http://localhost:8080/druid) (账号/密码: `admin/admin`) - **H2 控制台**: [http://localhost:8080/h2-console](http://localhost:8080/h2-console) (JDBC URL: `jdbc:h2:mem:testdb`) ## 7. 许可证 本项目采用 MIT 许可证。