此篇是上一篇AOP博客的延伸,本篇主要详细解释AOP如何使用注解,上一篇连接(https://blog.csdn.net/qq_28863191/article/details/101509503)
如何使用AOP注解
1.在配置文件中打开注解的AOP开发
application.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 在配置文件中开启注解的AOP的开发 -->
<aop:aspectj-autoproxy/>
<!-- 配置目标对象,被增强对象=================== -->
<bean id="productDao" class="com.ysx.spring.demo2.ProductDAOImpl" />
<!-- 将切面类交给Spring -->
<bean id="myAspect" class="com.ysx.spring.demo2.MyAspectXML" />
</beans>