spring 常用注解
- @Component:创建类对象,相当于配置<bean/>
- @Service:写在ServiceImpl类上
- @Repository:写在数据库访问层类上
- @Contoller:写在控制器类上
- @Resource(不需要写set/get方法)设置自动注入
- jdk中的注解
- 默认按照byName注入,如果没有名称对象,则按照byType注入
- 建议把对象名称和spring容器中对象名相同
- @Autowired(不需要set/get方法):设置自动注入
- spring的注解
- 默认按照byType注入
- @Value:获取properties文件中的内容
- @Pointercut:定义切点
- @Aspect:定义切面类
- @Before:前置通知
- @After:后置通知
- @AfterReturning:后置通知,切点必须正确执行
- @AfterThrowing:异常通知
- @Around:环绕通知

更多精彩