spring 整合mongodb报NoSuchMethodError错误
刚开始通过网上查到相关的资料进行了一些配置,参考链接:http://www.open-open.com/lib/view/open1454374782167.html
maven的dependencies如下:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.3.RELEASE</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.8.2.RELEASE</version>
</dependency>
spring-mongo.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/data/repository
http://www.springframework.org/schema/data/repository/spring-repository-1.5.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
">
<mongo:db-factory id="mongoDbFactory" host="127.0.0.1" port="27017" dbname="webusi" />
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /> </bean> </beans>
测试后一直提示,mongoTemplate创建时报错:
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
后来重新调整了spring-core的版本为4.1.3.RELEASE后,就ok了,难道真是版本不兼容的问题??
再次将spring-core版本调整为4.0.6,居然又不报错了,真是够诡异的。。。
spring 整合mongodb报NoSuchMethodError错误的更多相关文章
- spring整合mybatis报.UnsatisfiedDependencyException错误
tomcat启动报org.springframework.beans.factory.UnsatisfiedDependencyException:错误 org.springframework.bea ...
- spring整合quartz报错
今天spring整合quartz报错,最后一步步排查,发现是和redis依赖冲突,最后redis升级了一下,问题解决. 总结:发现问题,逐一排查,如果是整合问题,报类加载不到的错误,大概率是和其他组件 ...
- Spring整合MongoDB(转)
1.认识Spring Data MongoDB 之前还的确不知道Spring连集成Nosql的东西都实现了,还以为自己又要手动封装一个操作MongoDB的API呢,结果就发现了Spring Data ...
- MongoDB系列:四、spring整合mongodb,带用户验证
在前面的两篇博客 MongoDB常用操作练习.springboot整合mongoDB的简单demo中,我们基本上熟悉了mongodb,也把它与spring boot进行了整合并且简单使用.在本篇博客中 ...
- spring整合mongodb
使用spring整合mongodb maven 依赖 <dependency> <groupId>org.mongodb</groupId> <artifac ...
- spring整合junit报错
1.Could not autowire field: private javax.servlet.http.HttpServletRequest 参考:https://www.cnblogs.com ...
- 像我这样优雅地进行Spring整合MongoDB
本文重点是要将mongodb与spring整合到项目中去,在实践中发现问题,追踪问题,然后解决问题. 一.准备 Maven.Spring(spring-data-mongodb) spring Dat ...
- Spring整合Mybatis报 java.lang.ClassNotFoundException:org.springframework.core.metrics.ApplicationStartup,即:spring的版本过高,采用RELEASE稳定版
1.遇到的问题: 今天在弄spring整合mybatis的时候遇到一个小问题,如图所示: 简单来说:就是我的spring的xml文件没找到,我就奇了怪了,我所有的配置都没问题啊! 我pom.xml配置 ...
- Spring整合Hibernate报错:annotatedClasses is not writable or has an invalid setter method
Spring 整合Hibernate时报错: org.springframework.beans.factory.BeanCreationException: Error creating bean ...
随机推荐
- 灵活配置tomcat根目录网站
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDepl ...
- ubuntu 18.04安装ftp服务器
首先安装vsftpd: sudo apt-get install vsftpd 可以通过命令vsftpd -version查看vsftpd版本. 为ftp服务器新建一个用户(比如我这里新建一个用户名和 ...
- Eureka启动报错:Failed to load property source from location 'classpath:/application.yml'
原因: 将application.yml添加到classpath时, 由于变更了application.yml的编码格式(或许也改变了些代码内容), 而target内的yml文件没有实时更新, 从而导 ...
- 学习Yii(2)
Yii拥有很好的手册,还是中文的,官方的手册很详细.还是应该好好看一下.今天就开始跟着项目代码调试. 上次看到入口脚本,学习一定要快,要用心,抓住时间.不然时间拖久了就忘了.延续不上,大打折扣.而且要 ...
- layer简单使用
官方:https://www.layui.com/doc/modules/layer.html 源码:https://github.com/xiaostudy/web_sample 效果 目录结构 代 ...
- HTML 全局属性 = HTML5 中添加的属性。
属性 描述 accesskey 规定激活元素的快捷键. class 规定元素的一个或多个类名(引用样式表中的类). contenteditable 规定元素内容是否可编辑. contextmenu 规 ...
- 初识RedisCluster集群
为什么需要Redis集群 需要提高更大的并发量 Redis官方提出拥有10万QPS的请求量 如果业务需要Redis拥有100万的QPS 可以通过集群来提升并发量. 需要存储更大的数据量 一般服务器的机 ...
- python中int是什么类型
python中的基本数据类型 1:虽然python中的变量不需要声明,但使用时必须赋值整形变量浮点型变量字符型2:可以一个给多个变量赋值,也可以多个给多个变量赋值3:python3中有6个标准数据类型 ...
- taskverse学习
简介 taskverse是<linux二进制分析>一书作者编写的一个隐藏进程的检测工具,它使用/proc/kcore来访问内核内存,github的地址在这里:https://github. ...
- 第6章:使用Python监控Linux系统
1.Python编写的监控工具 1).多功能系统资源统计工具dstat dstat是一个用Python编写的多功能系统资源统计工具,用来取代Linux下的vmstat,iostat,netstat和i ...