今天在用MyEclipse学习spring AOP,在实现MethodBeforeAdvice 这个接口时
代码如下:

 1 package com.pdsu.aop;
 2 
 3 import java.lang.reflect.Method;
 4 
 5 import org.springframework.aop.MethodBeforeAdvice;
 6 
 7 public class MethodBeforeIntercptor implements MethodBeforeAdvice{//此行报错
 8 
 9     @Override
10     public void before(Method arg0, Object[] arg1, Object arg2)
11             throws Throwable {
12         
13     }
14 
15 }

报这个错误:The type org.aopalliance.aop.Advice cannot be resolved. It is indirectly referen......
从网上搜索了一下找到了解决方法如下
导入spring.jar(下带的org.aopalliance.*),因为Spring的aop的实现遵守了AOP联盟的约定,也就是它的advice都实现了org.aopalliance.aop.Advice接口。
我用的是3.05版本,因为spring在3.0及其以上版本就不再完整的将依赖打包,而是分成了很多模块。所以在dist目录下找不到spring.jar了。为此只需要下载2.6.x版本将里面的spring.jar拷贝出来即可。最后就是在代码中加入
import org.aopalliance.*;

到此o了!

 

转载于:https://www.cnblogs.com/wuyulunbi/archive/2012/12/23/exception_1.html

Logo

昇腾计算产业是基于昇腾系列(HUAWEI Ascend)处理器和基础软件构建的全栈 AI计算基础设施、行业应用及服务,https://devpress.csdn.net/organization/setting/general/146749包括昇腾系列处理器、系列硬件、CANN、AI计算框架、应用使能、开发工具链、管理运维工具、行业应用及服务等全产业链

更多推荐