我正在尝试将Spring Data用于MongoDB。我正在使用MongoDB的全文搜索功能,并希望为文本索引字段(@TextIndexed
)尝试Spring Data注释。此功能在Spring Data MongoDB的1.6.0.BUILD-SNAPSHOT中可用。
我正在尝试在Spring中设置简单的应用程序上下文并运行简单的JUnit测试。但是我的应用程序上下文加载失败,因为我将1.5.1.RELEASE更改为1.6.0.BUILD-SNAPSHOT。
我得到的错误如下:
Caused by: org.springframework.beans.BeanInstantiationException: Could
not instantiate bean class
[org.springframework.data.mongodb.core.MongoTemplate]: Constructor
threw exception; nested exception is java.lang.NoClassDefFoundError:
org/springframework/objenesis/ObjenesisStd at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163) at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:121) at
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
... 51 more Caused by: java.lang.NoClassDefFoundError:
org/springframework/objenesis/ObjenesisStd at
org.springframework.data.mongodb.core.convert.DefaultDbRefResolver.<init>(DefaultDbRefResolver.java:72) at
org.springframework.data.mongodb.core.MongoTemplate.getDefaultMongoConverter(MongoTemplate.java:1961) at
org.springframework.data.mongodb.core.MongoTemplate.<init>(MongoTemplate.java:210) at
org.springframework.data.mongodb.core.MongoTemplate.<init>(MongoTemplate.java:174) at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at
java.lang.reflect.Constructor.newInstance(Constructor.java:513) at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
... 53 more Caused by: java.lang.ClassNotFoundException:
org.springframework.objenesis.ObjenesisStd at
java.net.URLClassLoader$1.run(URLClassLoader.java:202) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:190) at
java.lang.ClassLoader.loadClass(ClassLoader.java:306) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at
java.lang.ClassLoader.loadClass(ClassLoader.java:247)
现在,我试图通过使用grepcode.com来确定哪个JAR包含org.springframework.objenesis.ObjenesisStd
,但它无法返回任何与Spring相关的JAR。
我在这里缺少什么?
答案 0 :(得分:21)
Spring Data MongoDB 1.6将需要release train's wiki page所示的Spring Framework 4。 Spring Framework 4包含异常抱怨的类。