使用Spring4.2.5.RELEASE和MongoDB2.0.0.RELEASE,采用封装MongoTemplate方式,无法序列化对象

zwk_Java 2017-10-15 03:02:53
我在配置MongoDB的时候,使用MongoTemplate方式去操作MongoDB,但是在配置的时候发现无法使用svae()方法对domain进行保存,如果使用Json工具将对象转化为Json数据的话就可以保存到mongoDB。报如下错误
严重: Servlet.service() for servlet [springServlet] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.util.Assert.isTrue(ZLjava/util/function/Supplier;)V] with root cause
java.lang.NoSuchMethodError: org.springframework.util.Assert.isTrue(ZLjava/util/function/Supplier;)V
at org.springframework.data.mapping.model.BasicPersistentEntity.getPropertyAccessor(BasicPersistentEntity.java:427)
at org.springframework.data.mongodb.core.MongoTemplate.assertUpdateableIdIfNotSet(MongoTemplate.java:1563)
at org.springframework.data.mongodb.core.MongoTemplate.doSave(MongoTemplate.java:1262)
at org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:1212)
at com.rongdu.cashloan.core.mongo.service.TestService.save(TestService.java:30)
at com.rongdu.cashloan.core.mongo.service.TestService$$FastClassBySpringCGLIB$$34a70ff2.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
这是我的spring配置文件:

有哪位大神对这方面了解的,求教
...全文
1422 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
情迷兰帕德 2018-06-19
  • 打赏
  • 举报
回复
应该是spring 4.x 和 spring-data-mongo 2.x 系列依赖冲突了,要改一下依赖版本
qq_26067299 2018-01-16
  • 打赏
  • 举报
回复
你的spring dada jpa 应该是比较新的版本,而在新版本中的spring data jap,不支持spring4.x系列,官网文档spring集成mongodb配置,需要用spring5.x系列才可以,把jar包换了就可以了
qq_35387286 2017-11-25
  • 打赏
  • 举报
回复
你好,请问这个难题你解决了吗?我也遇到了
zwk_Java 2017-10-16
  • 打赏
  • 举报
回复
大神们来帮帮忙啊!跪谢
zwk_Java 2017-10-16
  • 打赏
  • 举报
回复
代码是在业务代码中发生的错误,确切位置在BasicPersistentEntity类中的getPropertyAccessor(Object bean)方法中第二条语句 发生错误,是spring-data-Commons 包中的类
tianfang 2017-10-16
  • 打赏
  • 举报
回复
Assert错误,是不是junit中的吧,重新导入一下 org.springframework.util.Assert.isTrue(ZLjava/util/function/Supplier;)V
zwk_Java 2017-10-15
  • 打赏
  • 举报
回复
求大神解惑,万分感谢

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧