Skip to content

A production-ready REST API template featuring JWT authentication with Spring Security, JPA Specifications for dynamic queries, Redis caching, and MySQL containerized deployment. Includes Swagger documentation, unified exception handling, pagination support, and transactional management for rapid backend development.

Notifications You must be signed in to change notification settings

jyoketsu/spring-boot-template

Repository files navigation

Spring-boot-template

目录结构

├── model           实体类
├── dto             数据传输对象
├── repository      数据层
├── service         业务层
├── controller      API层
├── config          JPA审计,全局拦截(advice)
├── util            工具类
└── exception       异常处理

RESTful Web Service

HelloController.java

Entity

BaseEntity
NamedEntity
Dictionary
Ingredient

DTO

IngredientBodyDTO AuthRequestDTO

JPA

IngredientRepository.java

MySQL

JPA 审计

  • 引入 Spring Data JPA 的 @EnableJpaAuditing 以启用自动时间管理,例:JpaConfig.java
  • @CreatedDate @LastModifiedDate,例:BaseEntity.java

多对一

多个当前实体对象Ingredient可以对应一个关联的目标实体对象Dictionary

多对多

Recipe(菜谱)和Ingredient(食材)是多对多,创建中间实体RecipeIngredient

@JsonIgnore

Ingredient.java

投影 Projection

RecipeRepository.java

JPQL

RecipeRepository.java

NativeSQL

RecipeRepository.java

@JsonFormat

BaseEntity RecipeProjection RecipeSummaryDTO

分页查询

统一响应格式

ApiResponse.java

分页响应格式

PageResponse.java

异常处理

复杂动态查询

根据名称和单位动态查询食材

GET /ingredients/search?name=鸡蛋&unit=1

基于菜谱名、描述和多个食材名的动态查询

GET /recipes/list/search?name=面条&description=辣&ingredients=肉丝 青椒

Redis 缓存

Docker

Transaction

lombok

User.java RecipeIngredientId.java

Spring Security & JWT (注册登录)

角色权限

密码加密存储:BCrypt

AccessToken & RefreshToken

Kaptcha

Actions

备份数据库

恢复数据库

About

A production-ready REST API template featuring JWT authentication with Spring Security, JPA Specifications for dynamic queries, Redis caching, and MySQL containerized deployment. Includes Swagger documentation, unified exception handling, pagination support, and transactional management for rapid backend development.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published