In spring boot mvc project with pure java configuration how to configure Jackson to omit lazy load Attributes
With recent versions of Spring Boot this is much easier.
Any beans of type com.fasterxml.jackson.databind.Module will be automatically registered with the auto-configured Jackson2ObjectMapperBuilder and applied to any ObjectMapper instances that it creates. This provides a global mechanism for contributing custom modules when you add new features to your application.
74.3 Customize the Jackson ObjectMapper
First ensure you have the required Jackson dependency:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate4</artifactId>
</dependency>
You can then just include the module as a @Bean
in the application context.
@Bean
public Module hibernate4Module()
{
return new Hibernate4Module();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With