spring aop java实现
时间: 2023-09-22 12:13:00 浏览: 201
Spring AOP的Java实现有两种方式: 编译时增强和运行时增强。编译时增强是在编译阶段生成代理类,其中AspectJ是一个基于Java实现的AOP框架,它有自己的编译器或织入器,需要使用AspectJ的编译器编译切面类才能执行。而运行时增强是在运行时动态生成代理类,其中JDK动态代理和CGLIB库是两种常用的实现方式。JDK动态代理只能代理接口,而CGLIB能代理接口和类,但不能代理被final修饰的类。JDK动态代理通过反射生成代理类,而CGLIB通过继承被代理类的方式生成代理类。Spring AOP使用了AspectJ的注解来定义切面、切入点、通知增强等,但没有使用AspectJ的代理类生成实现,所以不需要额外的AspectJ编译器或织入器。Spring AOP同时实现了通过JDK动态代理和CGLIB来生成代理类,当目标类实现了接口时,默认使用JDK动态代理,当目标类没有实现接口时,使用CGLIB。Spring AOP的切面类(用@Aspect注解标注的类)也是由IOC容器管理的Bean。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [理解Spring AOP实现与思想 案例代码](https://download.csdn.net/download/qq_37171817/12502814)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Java自定义注解、Spring AOP、使用AOP实现和自定义注解实现日志记录](https://blog.csdn.net/suiyishiguang/article/details/126612592)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [java AOP实现方式及Spring AOP总结](https://blog.csdn.net/wenqiangluyao/article/details/126309757)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)