去除多余的null的key ,修正kafka的broker地址

This commit is contained in:
zhouxiunai
2018-12-10 10:06:13 +08:00
parent 4dc555e349
commit a0ad9c8d61
4 changed files with 31 additions and 3 deletions
@@ -0,0 +1,23 @@
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;
}
}
@@ -27,6 +27,8 @@ public class KafkaProducerConfig {
private int linger;
@Value("${kafka.producer.buffer.memory}")
private int bufferMemory;
@Value("${kafka.producer.max.request.size}")
private int maxRequestSzie;
public Map<String, Object> producerConfigs() {
@@ -36,6 +38,7 @@ public class KafkaProducerConfig {
props.put(ProducerConfig.BATCH_SIZE_CONFIG, batchSize);
props.put(ProducerConfig.LINGER_MS_CONFIG, linger);
props.put(ProducerConfig.BUFFER_MEMORY_CONFIG, bufferMemory);
props.put(ProducerConfig.MAX_REQUEST_SIZE_CONFIG,maxRequestSzie);
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
return props;