gpt4 book ai didi

java - 创建名称为 'mongoTemplate' 的 bean 时出错

转载 作者:太空宇宙 更新时间:2023-11-04 13:41:43 25 4
gpt4 key购买 nike

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class com.socketcruiter.config.SpringMongoConfig: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.mongodb.core.MongoTemplate org.springframework.data.mongodb.config.AbstractMongoConfiguration.mongoTemplate() throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mappingMongoConverter' defined in class com.socketcruiter.config.SpringMongoConfig: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.mongodb.core.convert.MappingMongoConverter org.springframework.data.mongodb.config.AbstractMongoConfiguration.mappingMongoConverter() throws java.lang.Exception] threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.data.util.ClassTypeInformation.from(Ljava/lang/Class;)Lorg/springframework/data/util/ClassTypeInformation;

我有以下配置

<mongo:mongo host="127.0.0.1" port="27017" />
<mongo:db-factory dbname="ssss" />

<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
</bean>

我正在使用 org.springframework.data spring 数据 mongodb 1.7.1.发布

最佳答案

检查类路径中是否有正确的 jar。您需要 spring-data-commons-core jar,这是最新版本: http://mvnrepository.com/artifact/org.springframework.data/spring-data-commons-core/1.4.1.RELEASE

关于java - 创建名称为 'mongoTemplate' 的 bean 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31190794/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com