类 BaseConfig
java.lang.Object
top.tangyh.basic.boot.config.BaseConfig
@AutoConfigureBefore(org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration.class)
public abstract class BaseConfig
extends Object
基础配置类
- 作者:
- zuihou
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明解决 @RequestParam(value = "date") Date date date 类型参数 格式问题getSpringUtils(org.springframework.context.ApplicationContext applicationContext) Spring 工具类gateway 网关模块需要禁用 spring-webmvc 相关配置,必须通过在类上面加限制条件方式来实现, 不能直接Bean上面加com.fasterxml.jackson.databind.ObjectMapperjacksonObjectMapper(org.springframework.http.converter.json.Jackson2ObjectMapperBuilder builder) 全局配置 序列化和反序列化规则 addSerializer:序列化 (Controller 返回 给前端的json) 1.解决 @RequestParam(value = "time") LocalDate timeorg.springframework.core.convert.converter.Converter<String,LocalDateTime> 解决 @RequestParam(value = "time") LocalDateTime time解决 @RequestParam(value = "time") LocalTime time
-
构造器详细资料
-
BaseConfig
public BaseConfig()
-
-
方法详细资料
-
jacksonObjectMapper
@Bean @Primary @ConditionalOnClass(com.fasterxml.jackson.databind.ObjectMapper.class) @ConditionalOnMissingBean public com.fasterxml.jackson.databind.ObjectMapper jacksonObjectMapper(org.springframework.http.converter.json.Jackson2ObjectMapperBuilder builder) 全局配置 序列化和反序列化规则 addSerializer:序列化 (Controller 返回 给前端的json) 1. Long -> string 2. BigInteger -> string 3. BigDecimal -> string 4. date -> string 5. LocalDateTime -> "yyyy-MM-dd HH:mm:ss" 6. LocalDate -> "yyyy-MM-dd" 7. LocalTime -> "HH:mm:ss"addDeserializer: 反序列化 (前端调用接口时,传递到后台的json) 2. "yyyy-MM-dd HH:mm:ss" -> LocalDateTime 3. "yyyy-MM-dd" -> LocalDate 4. "HH:mm:ss" -> LocalTime
- 参数:
builder- 构造器- 返回:
- 全局 ObjectMapper
-
dateConvert
解决 @RequestParam(value = "date") Date date date 类型参数 格式问题 -
localDateConverter
@Bean public org.springframework.core.convert.converter.Converter<String,LocalDate> localDateConverter()解决 @RequestParam(value = "time") LocalDate time -
localTimeConverter
@Bean public org.springframework.core.convert.converter.Converter<String,LocalTime> localTimeConverter()解决 @RequestParam(value = "time") LocalTime time -
localDateTimeConverter
@Bean public org.springframework.core.convert.converter.Converter<String,LocalDateTime> localDateTimeConverter()解决 @RequestParam(value = "time") LocalDateTime time -
getSpringUtils
@Bean public SpringUtils getSpringUtils(org.springframework.context.ApplicationContext applicationContext) Spring 工具类- 参数:
applicationContext- 上下文
-
getUndertowServerFactoryCustomizer
@Bean @ConditionalOnProperty(prefix="lamp.webmvc", name="undertow", havingValue="true", matchIfMissing=true) @ConditionalOnClass(io.undertow.Undertow.class) public UndertowServerFactoryCustomizer getUndertowServerFactoryCustomizer()gateway 网关模块需要禁用 spring-webmvc 相关配置,必须通过在类上面加限制条件方式来实现, 不能直接Bean上面加
-