I have a simple controller that return a User object, this user have a attribute coordinates that have the hibernate property FetchType.LAZY.
When I try to get this
This is similar to accepted solution by @rick.
If you don't want to touch existing message converters configuration you can just declare a Jackson2ObjectMapperBuilder
bean like:
@Bean
public Jackson2ObjectMapperBuilder configureObjectMapper() {
return new Jackson2ObjectMapperBuilder()
.modulesToInstall(Hibernate4Module.class);
}
Do not forget to add the following dependency to your Gradle file (or Maven):
compile 'com.fasterxml.jackson.datatype:jackson-datatype-hibernate4:2.4.4'
Useful if you have a spring-boot application and you want to keep the ability to modify Jackson features from application.properties
file.