19-Feb-2016 00:00:16.731 SEVERE [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.data.mongodb.core.MongoTemplate com.test.app.service.PersonService.mongoTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.data.mongodb.core.MongoTemplate]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.core.convert.support.ConversionServiceFactory.createDefaultConversionService()Lorg/springframework/core/convert/support/GenericConversionService;
<beans xmlns="http://www.springframework.org/schema/beans"
\t xmlns:context="http://www.springframework.org/schema/context"
\t xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
\t xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.2.xsd">
<context:component-scan base-package="com.test.app" />
<mvc:annotation-driven/>
\t <bean
\t \t class="org.springframework.web.servlet.view.InternalResourceViewResolver">
\t \t <property name="prefix">
\t \t \t <value>/WEB-INF/</value>
\t \t </property>
\t \t <property name="suffix">
\t \t \t <value>.jsp</value>
\t \t </property>
\t </bean>
<!-- Factory bean that creates the Mongo instance -->
\t <bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean">
\t \t <property name="host" value="localhost" />
\t </bean>
\t
\t
\t <!-- MongoTemplate for connecting and querying the documents in the database -->
\t <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
\t \t <constructor-arg name="mongo" ref="mongo" />
\t \t <constructor-arg name="databaseName" value="test" />
\t </bean>
\t <!-- Use this post processor to translate any MongoExceptions thrown in @Repository annotated classes -->
\t <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
\t
\t <bean id="personController" class="com.test.app.controller.PersonController" />
<bean id="personService" class="com.test.app.service.PersonService" />
<bean id="person" class="com.test.app.model.Person" />
\t
\t
</beans>
我看到關於此錯誤的許多職位,但沒有答案,解決這個問題。
這似乎適用於我 - 版本匹配似乎很愚蠢,但它的工作原理。令人沮喪 - 但謝謝! – Alin