抱歉打扰大家,最近在看spring in  action  ,看到aop 的一个小例子,怎么弄也是有问题。请大家帮忙,谢了。
类package lambert.springInaction.chapter1.aop;/**
 * @author zhixinl
 *
 */
public interface Knight {
public void exequest();
}package lambert.springInaction.chapter1.aop;public class TableRoundKnight implements Knight {
private String name;
public TableRoundKnight(String name) {
super();
this.name = name;
}
public TableRoundKnight() {
super();
// TODO Auto-generated constructor stub
}
public void exequest(){
System.out.println("TableRoundKnight method exequest called !");
}
}/**
 * 
 */
package lambert.springInaction.chapter1.aop;
import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
/**
 * @author zhixinl
 *
 */
public class Minstrel { public Minstrel() {
super();
// TODO Auto-generated constructor stub
} private static final Logger SONG = Logger.getLogger(Minstrel.class);

public void singBefore(JoinPoint joint){
SONG.info("Fa lala ,Sir " +" is so brave!"+ joint.getSignature());
}

public void singAfter(JoinPoint joint){
SONG.info("Theee ,Sir "+" is not so brave!" + joint.getSignature());
}
}
aop.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"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
   http://www.springframework.org/schema/aop
   http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
   http://www.springframework.org/schema/tx 
   http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="minstrel"
class="lambert.springInaction.chapter1.aop.Minstrel" />

<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<bean id="knight"
class="lambert.springInaction.chapter1.aop.TableRoundKnight" />

<aop:config>
<aop:aspect id="myaspect" ref="minstrel">
<aop:pointcut id="questPointCut"
expression="execution(* *.springInaction.chapter1.aop.Knight.*(..))" />
<aop:before method="singBefore"
pointcut-ref="questPointCut" />
<aop:after-returning method="singAfter"
pointcut-ref="questPointCut" />
</aop:aspect>
</aop:config>
</beans>测试类:package lambert.springInaction.chapter1.aop;import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class Exec { private static final String PATH1 = "lambert/springInaction/chapter1/aop/aop.xml"; public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext(
new String[] { PATH1 });

Knight knight = (Knight)ctx.getBean("knight");
knight.exequest();
}
}

解决方案 »

  1.   

    补充下啊,就是aop 这样弄了后不管用。只有这个 TableRoundKnight method exequest called !  被打印出来
      

  2.   

    Fa lala ,Sir  is so brave!org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint$MethodSignatureImpl@14e3f41
    TableRoundKnight method exequest called !
    Theee ,Sir  is not so brave!org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint$MethodSignatureImpl@14e3f41正常,我没有任何修改,直接打印出来了。
      

  3.   

    大家谁能将那些包给俺发下啊。
    [email protected]
      

  4.   

    原因不在此,谢谢大家的热心,汗。。是log4j 的问题