New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

springboot-api-template

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

springboot-api-template

Spring Boot 企业级项目脚手架,快速创建基于 Spring Boot 3.5.5 + MyBatis-Plus + JWT + Redis 的 API 项目

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Spring Boot API 项目脚手架

🚀 基于 Spring Boot 3.5.5 的企业级 API 项目脚手架,提供完整的基础设施和最佳实践。

📋 特性

  • ✅ Spring Boot 3.5.5
  • ✅ MyBatis-Plus 3.5.7
  • ✅ JWT 认证
  • ✅ Redis 缓存
  • ✅ HikariCP 连接池
  • ✅ Knife4j API 文档
  • ✅ Docker 支持
  • ✅ 统一响应格式
  • ✅ 全局异常处理
  • ✅ 参数校验
  • ✅ 逻辑删除
  • ✅ 自动填充
  • ✅ 短信验证码登录
  • ✅ 微信登录支持

🛠️ 安装

方式一:全局安装(推荐)

npm install -g springboot-api-template

方式二:使用 npx(无需安装)

npx springboot-api-template my-api

🚀 快速开始

创建新项目

# 方式一:使用全局安装的命令
create-springboot-api my-api

# 方式二:使用 npx
npx springboot-api-template my-api

# 方式三:交互式创建
create-springboot-api

创建项目时,脚本会提示你输入:

  • 项目名称
  • 项目描述
  • 包名前缀(如:com.company)
  • 作者姓名
  • 数据库名称
  • 数据库地址和端口

1. 安装脚手架

# 全局安装
npm install -g springboot-api-template

# 或者直接使用 npx
npx springboot-api-template my-api

2. 创建项目

# 使用 npx 创建项目
npx springboot-api-template my-api

# 或者使用全局命令
create-springboot-api my-api

3. 进入项目并启动

cd my-api
cp .env.example .env
# 修改 .env 文件中的配置
mysql -u root -p < sql/schema.sql
mvn spring-boot:run

4. 访问接口文档

打开浏览器访问: http://localhost:8080/doc.html

🛠️ 技术栈

  • Spring Boot: 3.5.5
  • MyBatis-Plus: 3.5.7
  • JWT: 0.12.6
  • Redis: Spring Boot Starter
  • Druid: 1.2.25
  • Hutool: 5.8.34
  • Knife4j: 4.5.0

📚 使用方法

命令行使用

# 创建项目(使用默认配置)
npx springboot-api-template my-api

# 或者交互式创建
npx springboot-api-template

交互式配置

脚手架支持交互式配置以下信息:

  • 项目名称
  • 项目描述
  • 包名前缀
  • 作者姓名
  • 数据库名称
  • 数据库地址
  • 数据库端口

📝 项目结构

my-api/
├── src/
│   ├── main/
│   │   ├── java/com/myapi/
│   │   │   ├── common/          # 公共模块
│   │   │   │   ├── cache/       # 缓存封装
│   │   │   │   ├── config/      # 配置类
│   │   │   │   ├── exception/   # 异常类
│   │   │   │   ├── filter/      # 过滤器
│   │   │   │   ├── handler/     # 处理器
│   │   │   │   ├── result/      # 统一响应
│   │   │   │   └── utils/       # 工具类
│   │   │   ├── config/          # Spring 配置
│   │   │   │   ├── JacksonConfig
│   │   │   │   ├── MybatisPlusConfig
│   │   │   │   ├── RedisConfig
│   │   │   │   ├── SecurityConfig
│   │   │   │   └── Knife4jConfig
│   │   │   ├── infrastructure/   # 基础设施层
│   │   │   │   ├── oss/         # 对象存储
│   │   │   │   ├── sms/         # 短信服务
│   │   │   │   └── wechat/      # 微信服务
│   │   │   ├── module/          # 业务模块
│   │   │   │   ├── auth/        # 认证模块
│   │   │   │   └── user/        # 用户模块
│   │   │   └── Application.java  # 启动类
│   │   └── resources/
│   │       ├── application.yml   # 主配置
│   │       ├── application-dev.yml # 开发环境配置
│   │       ├── application-prod.yml # 生产环境配置
│   │       └── mapper/          # MyBatis XML
│   └── test/                    # 测试代码
├── sql/
│   └── schema.sql               # 数据库脚本
├── docker-compose.yml           # Docker 编排
├── Dockerfile                   # Docker 镜像
├── .env.example                 # 环境变量模板
└── README.md                    # 项目文档

🎯 开发规范

Git 提交规范

[新增] 新功能
[修复] Bug 修复
[优化] 代码优化
[重构] 代码重构
[文档] 文档更新
[配置] 配置修改

代码规范

  • 使用 @Data@RequiredArgsConstructor 简化代码
  • 统一响应格式 Result<T>
  • 统一异常处理 ServerException
  • RESTful 风格接口设计
  • 参数校验使用 @Validated@NotBlank 等注解

📚 API 文档

认证接口

  • 登录: POST /api/auth/login
  • 发送验证码: POST /api/auth/send-sms-code
  • 短信登录: POST /api/auth/sms-login
  • 微信登录: POST /api/auth/wechat-login
  • 退出登录: POST /api/auth/logout

用户管理

  • 获取个人信息: GET /api/user/profile
  • 更新个人信息: PUT /api/user/profile
  • 用户列表: GET /api/user/page

🐳 Docker 部署

# 构建镜像
docker build -t my-api:1.0.0 .

# 运行容器
docker-compose up -d

# 停止容器
docker-compose down

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT License

Keywords

springboot

FAQs

Package last updated on 19 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts