首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

spring的cglib有关问题

2012-09-21 
spring的cglib问题?xml version1.0 encodingUTF-8?beans xmlnshttp://www.springframework.org

spring的cglib问题
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="myPointcutAdvisor"
/>
</property>
<property name="patterns">
<list>
<value>.*do.*</value>
<value>.*action.*</value>
</list>
</property>

</bean>

<bean id="MyInterceptor" />
</property>

<property name="interceptorNames">
<value>myPointcutAdvisor</value>
</property>

</bean>
   <bean id="service" lazy-init="true" />
</beans>
测试代码
package com;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class Demo {

public static void main(String[] args) {
ApplicationContext cxt =
new FileSystemXmlApplicationContext("classpath:applicationContext.xml");
ServiceImpl service = (ServiceImpl)cxt.getBean("service");
System.out.println(service);
service.doTest();
}
}

这个配置相信大家都会,但是在Myeclipse6.0下导入spring的jar包。会报这个错误
net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
发现竟然是jar包不兼容导致。是Myeclipse6.0自动导入的spring的jar包问题。是自动导入的cglib包有问题。
自己实现cglib也出现过同样的问题。后面自己导入cglib包,发现少asm包,需要导入 hibernate包就可以正常运行。
解决方案:
  把自动导入的jar包删除。重新导入jar包即可。

热点排行