1.@Component 创建类对象,相当于配置。
2.@Service与@Component功能相同,现在ServiceImpl类上,具体情况具体来。
3.@Repository与@Component功能相同,现在数据访问层类上的。
4.@Controller与@Component功能相同,写在控制器类上的。
总结@Component,@Service,@Repository,@Controller
注解 | 含义 |
---|---|
@Component | 最普通的组件,可以被注入到spring容器进行管理 |
@Service | 作用于业务逻辑层 |
@Repository | 作用于持久层 |
@Controller | 作用于表现层(spring-mvc的注解) |
5.@Resource(不需要写对象的get/set)
5.1 java中的注解
5.2 默认按照byName注入,如果没有名称对象,按照byType注入
6.@Autowired(不需要写对象的get/set)
6.1 spring的注解
6.2 默认按照byType注入
7.@value()获取properties文件中内容
8.@Pointcut()定义切点
9.@Aspect()定义切面类
10.@Before()前置通知
11.@After后置通知
12.@AfterReturning后置通知,必须切点正确执行
13.@AfterThrowing异常通知
14.@Arround环绕通知