Skip to content

常用注解速查 ​

注解说明
@SpringBootApplication启动类注解(含 @Configuration + @EnableAutoConfiguration + @ComponentScan)
@RestControllerRESTful 控制器
@RequestMappingURL 映射
@GetMapping / @PostMappingHTTP 方法映射
@PathVariableURL 路径变量
@RequestParam查询参数
@RequestBody请求体
@ResponseBody响应体
@Service服务层
@Repository数据访问层
@Component通用组件
@Autowired依赖注入
@Value配置值注入
@ConfigurationProperties类型安全的配置绑定
@Transactional事务管理
@Cacheable / @CacheEvict缓存
@Async异步方法
@Scheduled定时任务
@ExceptionHandler异常处理
@ControllerAdvice全局异常处理
@Validated参数校验

Released under the MIT License.