Spring之路—常用注解收集

【@Component】——标注一个普通的Spring Bean类

【@Controller】——标注一个控制器组件类

【@Service】——标注一个业务逻辑组件类

【@Repository】——标注一个Dao的组件类

【@Bean】——标示为一个bean

【@ComponentScan】——自定义扫描路径装配bean

【@Configuration】——标示一个配置类

【@EnableAutoConfiguration】——spring自动装配可能依赖的bean

【@SpringBootApplication】springboot的组合注解,整合了@Configuration,@EnableAutoConfiguration,@ComponentScan注解

【@ImportResource】——用来导入xml配置文件,比如某些配置一定要xml配置。

【@RequestParam/@PathVariable】——用于从request中接收请求的,两个都可以接收参数,关键点不同的是@RequestParam 是从request里面拿取值,而 @PathVariable 是从一个URI模板里面来填充
 

http://localhost:8080/springmvc/hello/101?param1=10&param2=20

@RequestMapping("/hello/{id}")
    public String getDetails(@PathVariable(value="id") String id,
    @RequestParam(value="param1", required=true) String param1,
    @RequestParam(value="param2", required=false) String param2){
.......
}

【@DeclareParents】——Aspectj提供的,在使用基于Aspectj注解的Spring Aop时,我们可以在切面中通过@DeclareParents指定满足指定表达式的类将自动实现某些接口

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章