@AutoConfigureBefore(value=org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration.class) public abstract class BaseConfig extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
BaseConfig.WebMvcConfig
gateway 网关模块需要禁用 spring-webmvc 相关配置,必须通过在类上面加限制条件方式来实现, 不能直接Bean上面加
|
| 构造器和说明 |
|---|
BaseConfig() |
| 限定符和类型 | 方法和说明 |
|---|---|
org.springframework.core.convert.converter.Converter<String,Date> |
dateConvert()
解决 @RequestParam(value = "date") Date date
date 类型参数 格式问题
|
SpringUtils |
getSpringUtils(org.springframework.context.ApplicationContext applicationContext)
Spring 工具类
|
com.fasterxml.jackson.databind.ObjectMapper |
jacksonObjectMapper(org.springframework.http.converter.json.Jackson2ObjectMapperBuilder builder)
全局配置 序列化和反序列化规则
addSerializer:序列化 (Controller 返回 给前端的json)
1.
|
org.springframework.core.convert.converter.Converter<String,LocalDate> |
localDateConverter()
解决 @RequestParam(value = "time") LocalDate time
|
org.springframework.core.convert.converter.Converter<String,LocalDateTime> |
localDateTimeConverter()
解决 @RequestParam(value = "time") LocalDateTime time
|
org.springframework.core.convert.converter.Converter<String,LocalTime> |
localTimeConverter()
解决 @RequestParam(value = "time") LocalTime time
|
@Bean @Primary @ConditionalOnClass(value=com.fasterxml.jackson.databind.ObjectMapper.class) @ConditionalOnMissingBean public com.fasterxml.jackson.databind.ObjectMapper jacksonObjectMapper(org.springframework.http.converter.json.Jackson2ObjectMapperBuilder builder)
addDeserializer: 反序列化 (前端调用接口时,传递到后台的json) 1. {"code": "xxx"} -> BaseEnum 2. "yyyy-MM-dd HH:mm:ss" -> LocalDateTime 3. "yyyy-MM-dd" -> LocalDate 4. "HH:mm:ss" -> LocalTime
builder - 构造器@Bean public org.springframework.core.convert.converter.Converter<String,Date> dateConvert()
@Bean public org.springframework.core.convert.converter.Converter<String,LocalDate> localDateConverter()
@Bean public org.springframework.core.convert.converter.Converter<String,LocalTime> localTimeConverter()
@Bean public org.springframework.core.convert.converter.Converter<String,LocalDateTime> localDateTimeConverter()
@Bean public SpringUtils getSpringUtils(org.springframework.context.ApplicationContext applicationContext)
applicationContext - 上下文Copyright © 2023. All rights reserved.