spring查询出数据返回时报错:
Could not write JSON: Direct self-reference leading to cycle; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Direct self-reference leading to cycle (through reference chain: com.JsonResult[“data”]->java.util.ArrayList[0]->com.github.pagehelper.Page[0]->com.baiwang.cloud.common.model.BwBfDdxx[“data”]->oracle.sql.CLOB[“dbaccess”]->oracle.jdbc.driver.T4CConnection[“wrapper”])",
解决方案:
很明显和data有关,将data设置为空,或者不查出来就行。
不查出来需要改sql。
设置为空只要遍历set即可(这个简单点)。
但是有时确实需要data数据,那怎么办呢?
可以新建一个额外的dataString,将data的值转换后放到dataString中,然后data设为null,这样就可以了。