spring aop xml配制
<mvc:annotation-driven />
<aop:aspectj-autoproxy proxy-target-class="true"/>
<bean id="xmlAop" class="com.meizu.spring.xml_aop.XmlAop"/>
<aop:config>
<aop:aspect id="myAspect" ref="xmlAop">
<aop:pointcut id="aopPoint" expression="execution(* com.meizu.spring.service.*.add*(..))"/>
<aop:before method="start" pointcut-ref="aopPoint"/>
<aop:around method="around" pointcut-ref="aopPoint"/>
<aop:after method="after" pointcut-ref="aopPoint"/>
</aop:aspect>
</aop:config>
XmlAop 切面
public class XmlAop {
public void start(){
System.out.print("aop before");
}
public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
System.out.print("around before");
proceedingJoinPoint.proceed();
System.out.print("around after");
}
public void after(){
System.out.print("aop after");
}
}
ServiceInfo 切面作用域
@Service
public class ServiceInfo {
public void addInfo(){
System.out.print("info function");
}
}