I am trying to convert an object to JSON, below is the object
@Data
public class OraganisationStructures{
@Autowired
private OrganisationProperties organisationProperties;
....
...
}
I get the below exception and error. How do I handle this. This error is stopping my log appenders where the logs are getting vanished due to this error.
com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: java.util.concurrent.ConcurrentHashMap[" "]->com.java.sample.OraganisationStructures$$EnhancerBySpringCGLIB$$6c9f7932["organisationProperties"]->com.java.sample.OraganisationStructures$$EnhancerBySpringCGLIB$$99c7d84b["$$beanFactory"]->org.springframework.beans.factory.support.DefaultListableBeanFactory["singletonObjects"]at at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:706)
at at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155)
at at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:704)
at at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:690)
at at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155)
Use @JsonIgnore
to break the Infinite recursion in case you are with ignoring one side of mapping. Otherwise use @JsonManagedReference
, @JsonBackReference
for bi directional mapping.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.