npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

springboot-api-template

v1.0.0

Published

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

Downloads

10

Readme

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