Files
training/README.md
马宝龙 5e07c24dd4 初始化
2026-07-27 23:20:12 +08:00

63 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Training Full-Stack Project
前后端分离的全栈项目基础工程:
- `frontend`: React 18 + TypeScript + Vite
- `backend`: Spring Boot + Java 21 + Maven + MyBatis-Plus
- `MySQL`: 外部 MySQL 8 数据库,由环境变量提供连接配置
## 环境要求
- Node.js 20+
- JDK 21+
- Maven 3.9+(或使用项目中的 Maven Wrapper
- 可访问目标 MySQL 的网络和账号
## 配置数据库
项目不会创建或启动 MySQL。请先确保 `.env.example` 中配置的 MySQL 服务已经运行并允许当前机器访问。
Spring Boot 启动时按以下顺序读取配置:根目录 `.env`,然后是根目录 `.env.example`。同名变量以 `.env` 为准;没有 `.env` 时直接使用已配置的 `.env.example`
建议将 `.env.example` 复制为本地 `.env`,实际 `.env` 不提交到仓库:
```powershell
cp .env.example .env
```
生产环境使用 `.env.production.example` 作为 `.env` 模板,或由部署平台注入同名环境变量:
```powershell
cp .env.production.example .env
```
需要确认 `MYSQL_HOST``MYSQL_PORT``MYSQL_DATABASE``MYSQL_USER``MYSQL_PASSWORD` 均已配置。生产环境建议使用部署平台的 Secret 管理能力。
## 启动后端
```bash
mvn -f backend/pom.xml spring-boot:run
```
后端默认运行在 `http://localhost:8080`,健康检查地址为 `GET /api/health`
## 启动前端
```bash
cd frontend
npm install
npm run dev
```
前端默认运行在 `http://localhost:5173`,开发服务器会将 `/api` 请求代理到后端。
## 构建检查
```bash
cd frontend
npm run build
cd ../backend
mvn clean verify
```