这不是“全宇宙注解列表”,
而是 后端工程中 95% 会用到的注解清单。
一、组件与依赖注入(IoC)
把类交给 Spring 管理。
- @Component 通用组件
- @Service 业务层
- @Repository 数据层
- @Controller 控制器
- @RestController REST 接口
- @Autowired 自动注入
- @Qualifier 指定 Bean
- @Value 注入配置
- @Bean 注册对象
二、Web 接口映射
HTTP → 方法。
- @RequestMapping
- @GetMapping
- @PostMapping
- @PathVariable
- @RequestParam
- @RequestBody
- @ResponseBody
- @ControllerAdvice
- @ExceptionHandler
三、参数校验
接口质量核心。
- @Valid
- @NotNull
- @NotBlank
- @Size
- @Pattern
四、事务管理
数据库一致性核心。
- @Transactional
五、异步与定时
并发体系核心。
- @EnableAsync
- @Async
- @EnableScheduling
- @Scheduled
六、Spring Boot 启动与配置
工程化核心。
- @SpringBootApplication
- @Configuration
- @ConfigurationProperties
- @Profile
- @ComponentScan
七、AOP 切面
日志 / 权限 / 监控。
- @Aspect
- @Before
- @After
- @Around
八、缓存
- @EnableCaching
- @Cacheable
- @CachePut
- @CacheEvict
九、安全(权限)
- @PreAuthorize
- @Secured
- @EnableMethodSecurity
十、MyBatis
- @Mapper
- @MapperScan
- @Select
- @Insert
最终记忆口诀
组件注入 → 接口映射 → 参数校验
事务控制 → 异步调度 → 启动配置
切面日志 → 缓存优化 → 权限安全
总结
注解不是记住多少个,
而是知道它属于哪一层、解决什么问题。
当你看到一个 @,
你应该想到的是:
“它在告诉框架做什么。”



