json在将对象转换为json格式的数据的时候,出现了无限递归调用的情况

来源:互联网 发布:js打印乘法表 编辑:程序博客网 时间:2024/04/29 21:37

这是异常信息

org.codehaus.jackson.map.JsonMappingException: failed to lazily initialize a collection of role: com.book.persist.domain.jpa.sys.User.userLocationSet, could not initialize proxy - no Session (through reference chain: java.util.HashMap["domainPage"]->com.book.common.core.pojo.DomainPage["domains"]->java.util.ArrayList[0]->com.book.persist.domain.jpa.biz.BookUser["user"]->com.book.persist.domain.jpa.sys.User["userLocationSet"])

user–>userLocationSet 是一对多的关系

解决办法:可以在User类上面加上@JsonIgnoreProperties注解

@JsonIgnoreProperties(value = "userLocationSet")
0 0
原创粉丝点击