jar包
这里是有Aop的包,日志包
//使用aop时需要添加aop名称空间
xmlns:aop="http://www.springframework.org/schema/aop"
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
<?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-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd">
<!--里面内容自己写的可以不要 bean组件 aop 面向切面-->
<bean id="dao" class="cn.dao.impl.UserDaoImpl"/>
<bean id="service" class="cn.service.impl.UserServiceImpl">
<property name="dao" ref="dao"/>
</bean>
<bean id="theLogger" class="cn.advice.ServiceLogger"></bean>
<aop:config>
<!-- 定义切入点 -->
<aop:pointcut expression="execution(public * addNewUser(cn.entity.User))" id="pointcut"/>
<!-- 引用包含增强方法的 bean -->
<aop:aspect ref="theLogger">
<!-- 前置增强 method为方法名-->
<aop:before method="before" pointcut-ref="pointcut"/>
<!-- 后置增强 -->
<aop:after-returning method="afterReturning" pointcut-ref="pointcut" returning="result"/>
</aop:aspect>
</aop:config>
</beans>