1

我有抽象类:

public abstract ClassA {

 protected abstract void method1 {...}

另一个实现method1的类ClassB。

XML:

bean id="BaseBean" class="ClassB"

bean id="WorkBean" class="ClassA"
lookup-method="method1" bean="BaseBean"

在测试中:

$RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:test.xml"
public class Test ....

@Autowired
private IClass classA;

当我尝试运行此测试时,我收到错误:

java.lang.IllegalStateException: Failed to load ApplicationContext
....
Caused by: org.springframework.beans.factory.BeanCreationException: Error 
 creating   bean with name 'WorkBean' 
defined in class path resource [test.xml]: 
Instantiation of bean failed; nested exception is 
java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
....
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.CallbackFilter
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

我该如何解决?

4

1 回答 1

2

这是由于缺少依赖库 - cglib 造成的。

sourceforge 上的 cglib

于 2012-04-28T14:28:25.020 回答