Configure Jackson to omit lazy-loading attributes in Spring Boot

前端 未结 6 1746
滥情空心
滥情空心 2020-11-30 04:13

In spring boot mvc project with pure java configuration how to configure Jackson to omit lazy load Attributes

6条回答
  •  余生分开走
    2020-11-30 05:10

    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:

    
        com.fasterxml.jackson.datatype
        jackson-datatype-hibernate4
    
    

    You can then just include the module as a @Bean in the application context.

    @Bean
    public Module hibernate4Module()
    {
        return new Hibernate4Module();
    }
    

提交回复
热议问题