在学习aop编程时,写了一个小例子,
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.AfterReturningAdvice;
public ClassName implements MethodBeforeAdvice,AfterReturningAdvice
ClassName 报错 The hierarchy of the type ClassName is inconsistent,
在网上查了原因,说是间接引用的jar包没有被导入,
于是查看spring aop源码 ,发现
org.springframework.aop.MethodBeforeAdvice;
org.springframework.aop.AfterReturningAdvice; 并没有依赖于任何jar包,找不原因呀!
这下头真的大了。
正在一筹莫展之际,无意间发现其他project中有aopalliance-1.0.jar这个包,果断导入,测试一下看,
果然没有再报错,原来 aopalliance-1.0.jar 是AOP联盟的API包, 包含了针对面向切面的接口,Spring aop依赖此包。