错误信息如下:
org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: com.yangjf.entity.Admin["company"]->com.yangjf.entity.Company["admins"]->org.hibernate.collection.PersistentSet[0]->com.yangjf.entity.Admin["company"]->com.yangjf.entity.Company["admins"]->org.hibernate.collection.PersistentSet[0]->com.yangjf.entity.Admin["company"]->com.yangjf.entity.Company["admins"]->org.hibernate.collection.PersistentSet[0]->com.yangjf.entity.Admin["company"]->com.yangjf.entity.Company["admins"]->org.hibernate.collection.PersistentSet[0]->com.yangjf.entity.Admin["company"]
解决办法:
在所有的@ManyToOne的实体对象get方法前添加@JsonIgnore即可。
或许有别的的解决方法:可以参考 http://xiongyingqi.com/2015/10/14/2014-06-30-spring-mvc-jackson-enhance/