mongo和spring集成配置

12-03-12 wudexi
mongoDB与spring3.0集成配置,

在配置用引用org.springframework.data.document.mongodb.MongoTemplate jar包中有异常,但用

org.springframework.data.mongodb.core.MongoTemplate 正常,

[该贴被wudexi于2012-03-12 14:30修改过]

wudexi
2012-03-12 14:34
按照 Spring Data MongoDB hellword方法配置有以下异常:

[INFO,XmlBeanDefinitionReader,main] Loading XML bean definitions from class path resource [applicationContext.xml]

[INFO,GenericXmlApplicationContext,main] Refreshing org.springframework.context.support.GenericXmlApplicationContext@95c083: startup date [Mon Mar 12 14:28:46 CST 2012]; root of context hierarchy

[INFO,PropertyPlaceholderConfigurer,main] Loading properties file from class path resource [mongodb.properties]

[INFO,DefaultListableBeanFactory,main] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1742700: defining beans [propertyConfigurer,mongo,mongoTemplate]; root of factory hierarchy

[INFO,DefaultListableBeanFactory,main] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1742700: defining beans [propertyConfigurer,mongo,mongoTemplate]; root of factory hierarchy

Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.data.document.mongodb.MongoTemplate] for bean with name 'mongoTemplate' defined in class path resource [applicationContext.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/mapping/context/MappingContextAware

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1264)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)

at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1330)

at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:896)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:566)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)

at org.springframework.context.support.GenericXmlApplicationContext.<init>(GenericXmlApplicationContext.java:69)

at dao.test1.main(test1.java:16)

Caused by: java.lang.NoClassDefFoundError: org/springframework/data/mapping/context/MappingContextAware

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:620)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)

at java.net.URLClassLoader.access$000(URLClassLoader.java:56)

at java.net.URLClassLoader$1.run(URLClassLoader.java:195)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)

at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

at org.springframework.util.ClassUtils.forName(ClassUtils.java:257)

at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408)

at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1282)

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1253)

... 8 more

[该贴被wudexi于2012-03-12 14:36修改过]

[该贴被wudexi于2012-03-12 14:38修改过]

猜你喜欢