代码-springboot jackson序列化忽略null值
This commit is contained in:
@@ -6,17 +6,14 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.multipart.MultipartResolver;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
import org.springframework.web.servlet.config.annotation.*;
|
||||
|
||||
/**
|
||||
* Created by PaperCut on 2018/9/17.
|
||||
* spring mvc配置
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig extends WebMvcConfigurationSupport {
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
|
@@ -35,7 +35,6 @@ public class I18nMessageNacosAutoConfig {
|
||||
dNamespace = DEFAULT_NAMESPACE;
|
||||
}
|
||||
log.info("开始初始化国际化配置!应用名称:{},Nacos地址:{},提示语命名空间:{}", applicationName, serverAddr, dNamespace);
|
||||
initTip(null, true);
|
||||
WebLocaleConfig.locales.forEach(item -> {
|
||||
initTip(item, true);
|
||||
});
|
||||
|
@@ -3,14 +3,13 @@ package com.accompany.core.config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Configuration
|
||||
public class WebLocaleConfig extends WebMvcConfigurationSupport {
|
||||
public class WebLocaleConfig implements WebMvcConfigurer {
|
||||
|
||||
public static Locale Chinese = Locale.CHINESE;
|
||||
public static Locale English = Locale.ENGLISH;
|
||||
|
@@ -86,6 +86,7 @@ public class LuckySeaPushMsgService {
|
||||
FloatingMessageTemplate message = new FloatingMessageTemplate();
|
||||
message.setResourceType(needSpecialFloating ? ResourceTypeEnum.SVGA.name() : ResourceTypeEnum.IMAGE.name());
|
||||
message.setResourceContent(needSpecialFloating ? roomTipConfig.getSpecialFloatUrl() : roomTipConfig.getNormalFloatUrl());
|
||||
message.setResourceTop(21);
|
||||
message.setResourceWidth(375);
|
||||
message.setResourceHeight(60);
|
||||
message.setTemplate(I18NMessageSourceUtil.getMessageMap(I18nAlertEnum.LUCKY_SEA_FLOATING_MSG.getI18nId(), new Object[]{"nick", "rate", "goldNum"}));
|
||||
|
@@ -6,7 +6,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.*;
|
||||
|
||||
@Configuration
|
||||
public class WebInterceptorConfig extends WebMvcConfigurationSupport {
|
||||
public class WebInterceptorConfig implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 自己定义的拦截器类
|
||||
|
@@ -18,9 +18,9 @@ public class WebMessageConverterConfig extends WebMvcConfigurationSupport {
|
||||
@Bean
|
||||
public MappingJackson2HttpMessageConverter customJackson2HttpMessageConverter() {
|
||||
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
ObjectMapper objectMapper = new ObjectMapper()
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
|
||||
|
||||
jsonConverter.setObjectMapper(objectMapper);
|
||||
return jsonConverter;
|
||||
|
@@ -54,7 +54,6 @@
|
||||
<java-jwt.version>3.10.3</java-jwt.version>
|
||||
<ons-client.version>1.2.1</ons-client.version>
|
||||
<sitemesh.version>2.4.2</sitemesh.version>
|
||||
<jackson-mapper-asl.version>1.9.13</jackson-mapper-asl.version>
|
||||
<pagehelper.version>5.1.8</pagehelper.version>
|
||||
<jsoup.version>1.10.2</jsoup.version>
|
||||
<validation-api.version>2.0.1.Final</validation-api.version>
|
||||
@@ -66,7 +65,6 @@
|
||||
<orika-core.version>1.5.4</orika-core.version>
|
||||
<spring-security-oauth2-autoconfigure.version>2.0.1.RELEASE</spring-security-oauth2-autoconfigure.version>
|
||||
<aliyun-java-sdk-cloudauth.version>1.2.0</aliyun-java-sdk-cloudauth.version>
|
||||
<jackson-datatype-joda.version>2.1.1</jackson-datatype-joda.version>
|
||||
<mybatisplus.version>3.1.2</mybatisplus.version>
|
||||
<sud-mgp-auth-java.version>1.0.4</sud-mgp-auth-java.version>
|
||||
<redisson.version>3.16.8</redisson.version>
|
||||
@@ -377,12 +375,6 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<version>${jackson-mapper-asl.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
|
||||
|
Reference in New Issue
Block a user