Configuring ObjectMapper in Spring

前端 未结 12 1689
迷失自我
迷失自我 2020-11-22 10:46

my goal is to configure the objectMapper in the way that it only serialises element which are annotated with @JsonProperty.

In order to do

12条回答
  •  隐瞒了意图╮
    2020-11-22 11:03

    In Spring Boot 2.2.x you need to configure it like this:

    @Bean
    public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
        return builder.build()
    }
    

    Kotlin:

    @Bean
    fun objectMapper(builder: Jackson2ObjectMapperBuilder) = builder.build()
    

提交回复
热议问题