spring 整合mongodb报NoSuchMethodError错误
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了spring 整合mongodb报NoSuchMethodError错误,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2211字,纯文字阅读大概需要4分钟。
内容图文
![spring 整合mongodb报NoSuchMethodError错误](/upload/InfoBanner/zyjiaocheng/471/4bcce654ede84171b275ce4f164a98ab.jpg)
<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错误
标签:
本文系统来源:http://www.cnblogs.com/zhuxiangguo/p/5934949.html
内容总结
以上是互联网集市为您收集整理的spring 整合mongodb报NoSuchMethodError错误全部内容,希望文章能够帮你解决spring 整合mongodb报NoSuchMethodError错误所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。