读书人

spring aop解决方法

发布时间: 2012-01-29 21:39:32 作者: rapoo

spring aop
报 Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.



package advice;

import java.lang.reflect.Method;

import org.springframework.aop.MethodBeforeAdvice;

public class AdviceIn implements MethodBeforeAdvice{

public void after(){
System.out.println("befer");

}

public void before() {
System.out.println("befer");

}

public void before(Method arg0, Object[] arg1, Object arg2) throws Throwable {
System.out.println("befer");

}

}



package dao;

public class Call implements CallInterface {

public void calling(){
System.out.println("calling");
}


}





<bean id="call" class="dao.Call"></bean>

<bean id="advice" class="advice.AdviceIn"></bean>

<aop:config proxy-target-class="true">
<aop:aspect ref="advice" >
<aop:pointcut id="pointout" expression="execution(* dao.*.*(..))"/>
<aop:after pointcut-ref="pointout" method="after" />
<aop:before pointcut-ref="pointout" method="before"/>
</aop:aspect>
</aop:config>




报 Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.

请各位帮忙看下


[解决办法]
少包了,导入cglib-nodep-2.1_3.jar 这个包,在lib\cglib目录下
[解决办法]
下载个cglib的jar包加进去。spring的AOP是用cglib实现的。
[解决办法]
导入cglib-nodep-2.1_3.jar 这个包
[解决办法]
同意楼上意见
来晚列 没分哩
[解决办法]
你配的aspectObject(切面类)没有实现接口,没有CGLIB库的支持的话不能创建代理
你可以把AspectObject的方法提取出来放到一个接口中,而AspectObject实现改接口,这就是所谓的面向接口编程,如果你没实现接口,只能加入cglib库创建cglib代理
[解决办法]
cglib包不存在啊,导入即可得

读书人网 >J2EE开发

热点推荐