首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java相关 >

nested exception is org.springframework.aop.framework.AopConfigException:

2013-09-11 
Spring AO问题老是提示这样的错误Exception in thread main org.springframework.beans.factory.BeanCre

Spring AO问题
老是提示这样的错误
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loggerBean' defined in class path resource [test/applicationContext.xml]: 
Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Couldn't generate CGLIB subclass of class [class test.LogBean]:
 Common causes of this problem include using a final class or a non-visible class; nested exception is net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null

配置文件

<?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="loggerBean" name="loggerBean" class="test.LogBean"/>
<bean id="aopBean" class="test.AOPBean" />
<aop:config>
<aop:pointcut id="loggerCalls" 
expression="execution(public * *(..))" />

<aop:aspect id="logAspect" ref="loggerBean">
<aop:around pointcut-ref="loggerCalls" method="aroundLogCalls"/>
</aop:aspect>
</aop:config>

</beans>

LogBean.java文件
package test;

import org.aspectj.lang.ProceedingJoinPoint;


public class LogBean {
public Object aroundLogCalls(ProceedingJoinPoint joinPoint)throws Throwable{

System.out.println("before invoke method:"+joinPoint.getSignature().getName());

Object obj = joinPoint.proceed();

System.out.println("After invoke methond:"+joinPoint.getSignature().getName());

return obj;
}

}


AOPBean文件
package test;

public class AOPBean {
public void display(){
System.out.println("AOPBean.display()");
}

}


AOPMain文件
package test;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AOPMain {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ClassPathXmlApplicationContext factory =
new ClassPathXmlApplicationContext("test/applicationContext.xml");

AOPBean aopbean = (AOPBean)factory.getBeanFactory().getBean("aopBean");
aopbean.display();
}

}






[解决办法]

Java code
ClassPathXmlApplicationContext factory = new ClassPathXmlApplicationContext("test/applicationContext.xml");
[解决办法]
Couldn't generate CGLIB 说明少包了
[解决办法]
这是有关aop里面出的问题
他那个包有问题

热点排行