springboot注解
基本注解
IOC
- @SpringBootApplication:@SpringBootConfiguration+@EnableAutoConfiguration+@ComponentScan的结合体
- @SpringBootConfiguration:继承@Configuration,两者功能一直,表示该类是配置类。等同于xml配置
- @EnableAutoConfiguration:开启自动配置,加载所有符合条件的@Configuration到IOC中,通过@Import注解中的AutoConfigurationImportSelector类来扫描spring.factories文件,把定义的配置类引入的。
- @ComponentScan:指定的包及其子包下去找到component,并且加入IOC中(默认为标注的类所在的包及其子包),可以加filter来排除或者指定
- @ServletComponentScan:对@WebServlet、@WebFilter、@WebListener三个注解自动注册。
- @Bean:用@Bean标注方法等价于XML中配置的bean
- @Order:加载顺序,数字越小,优先级越高
AOP
- @Aspect:定义切面
- @Pointcut:定义切点
- @Before
- @After
- @Around
springMVC
映射
- @RestController:@Controller+@ResponseBody
- @RequestMapping:映射url,接受的http格式(POST/GET),请求和返回的内容类型,指定header
- @RequestBody:处理content-type不是默认的application/x-www-form-urlcoded编码的内容,通常把json绑定到具体的pojo类上
过滤器
监听器
资源引入
- @Import:引入java类到IOC容器中。
- @ImportResource:引入spring配置文件.xml
- @PropertySource:引入文件
- @ConfigurationProperties:处理properties类型文件
controller异常处理
- @ControllerAdvice:定义全局异常处理类
MQ注解
- @EnableJms:
- @JmsListener:监听摸个队列
缓存
定时任务
- @EnableScheduling:
- @Schedule:设定定时任务