和Spring1.X相比,Spring2.X使用AspectJ的语法来声明AOP.本人也真在学习.
package com.springinaction.chapter01.knight;
public class Tempimp implements Temp {
public void temp() {
System.out.println("jsong");
}
}
<?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-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="aa" class="com.springinaction.chapter01.knight.Tempimp"/>
<aop:config>
<aop:aspect id ="logAspect" ref="aa">
声明一个切面 id="随便定义" ref="引用上面的bean(aa)"
<aop:pointcut id="businessService" expression = "execution(* springinaction.chapter01.knight.Tempimp.temp(..))" />
声明一个切入点
<aop:around pointcut-ref="businessService" method="intercept"/>
通知
<aop:after pointcut-ref = "businessService" method ="temp"/>
声明通知
</aop:aspect>
</aop:config>
</beans>
结果还是会调用temp()方法.打印出jsong。
现在还在继续学些spring2.X。希望大家多多指教.有什么问题,大家互相学习