这是我的spring.xml文件,我在下面用整个代码放在那里,实际上问题来自于bean创建的MongoTemplate类对象它给出了异常NoSuchMethod。我还在下面提到了我的错误
posts
但我有错误,我在下面提到请帮我解决
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation=
"http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<mongo:mongo host="localhost" port="27017" id="mongo" />
<mongo:db-factory dbname="Ganesh" mongo-ref="mongo" id="mongoDbFactory" />
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
</bean>
<!-- <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongo" ref="mongo" />
<constructor-arg name="databaseName" value="ganesh" />
</bean> -->
<bean id="personDAO" class="com.springjdbc.mongojdbctemplateclass.MongoDBJDBCTemplate">
<constructor-arg name="mongoOps" ref="mongoTemplate"/>
</bean>
</beans>
答案 0 :(得分:0)
请将此jar(从下面的路径下载)添加到您的构建路径http://central.maven.org/maven2/org/springframework/data/spring-data-mongodb/1.0.0.RELEASE/spring-data-mongodb-1.0.0.RELEASE.jar
如果你正在使用maven add dependency:
{{1}}