24 lines
891 B
Java
24 lines
891 B
Java
package com.gzzn.omms.msgexchangeapi.config;
|
|||
|
|
|
||
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||
|
|
import org.springframework.context.annotation.Bean;
|
||
|
|
import org.springframework.context.annotation.Configuration;
|
||
|
|
import org.springframework.context.annotation.Primary;
|
||
|
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||
|
|
|
||
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||
|
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||
|
|
|
||
|
|
@Configuration
|
||
|
|
public class JacksonConfig {
|
||
|
|
|
||
|
|
@Bean
|
||
|
|
@Primary
|
||
|
|
@ConditionalOnMissingBean(ObjectMapper.class)
|
||
|
|
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
|
||
|
|
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
|
||
|
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||
|
|
return objectMapper;
|
||
|
|
}
|
||
|
|
}
|