已解决:com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Direct self-reference leading to

简介: 已解决:com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Direct self-reference leading to

问题描述


 查询的是时候报错com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Direct self-reference leading to 翻译了一下 大概是序列化的原因 还有就是循环自己调用自己的意思大概

bad6ed3479164dea82ccd8071da1aaf3.png

6b13894807d5483dbcdd809a14079f7d.png

于是我进行了debug调式 发现代码在自己设置自己领导的时候 堆栈内存溢出  


9395a08ce33a40f8824de447881184aa.png

原因


  堆栈内存溢出是因为自己里面有自己调用toString 就像递归无限循环一样 那么堆栈内存溢出


为什么会导致com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Direct self-


reference leading to 这是因为在Controller 返回数据的时候使用了@RestController 返回的数据是


json 而我刚好返回的是个page分页对象 page里面有个records集合对象 前面说了已经堆栈内存溢


出 那么在controller转为json的时候会造成无限递归引用异常 就是 spring mvc json 循环引用


解决方案

       查询到它的所属领导 直接赋值


893f04874f984a5eb0afa0201510e561.png


相关文章
Unable to interpret the implicit parameter configuration with dataType: , dataTypeClass: class java.
Unable to interpret the implicit parameter configuration with dataType: , dataTypeClass: class java.
580 0
|
6月前
|
Java Spring
NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge【已解决】
NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge【已解决】
48 0
|
4月前
Unsatisfied dependency expressed through field 'restTemplate';
Unsatisfied dependency expressed through field 'restTemplate';
88 0
|
7月前
Unsatisfied dependency expressed through field ‘baseMapper‘
Unsatisfied dependency expressed through field ‘baseMapper‘
48 2
|
7月前
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance
65 0
ValidationException: HV000183: Unable to load 'javax.el.ExpressionFactory'.
ValidationException: HV000183: Unable to load 'javax.el.ExpressionFactory'.
|
JSON Java 数据格式
jackson 转换报内存缢出:java.lang.OutOfMemoryError: GC overhead limit exceeded at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:141)
转换报内存缢出。 原因是查询数据时,在转json的数据太大,内存不足 解决方法:1、加内存(没有从根本上解决问题)。2、优化代码,例如减少查询,分页查询。
163 0
|
NoSQL Java Redis
Unsatisfied dependency expressed through field /Injection of autowired dependencies failed 解决方法
根据报错的关键字,大底的意思就是依赖方面的问题。
342 0
Error creating bean with name ‘userServiceImpl‘: Unsatisfied dependency expressed through field ‘bas
Error creating bean with name ‘userServiceImpl‘: Unsatisfied dependency expressed through field ‘bas
431 0
Unsatisfied dependency expressed through field ‘baseMapper‘; nested exception is org.springframewor
Unsatisfied dependency expressed through field ‘baseMapper‘; nested exception is org.springframewor
Unsatisfied dependency expressed through field ‘baseMapper‘; nested exception is org.springframewor