类 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
  • 嵌套类概要

    嵌套类
    修饰符和类型
    说明
    static final class 
    gateway 网关模块需要禁用 spring-webmvc 相关配置,必须通过在类上面加限制条件方式来实现, 不能直接Bean上面加
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    org.springframework.core.convert.converter.Converter<String,Date>
    解决 @RequestParam(value = "date") Date date date 类型参数 格式问题
    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>
    解决 @RequestParam(value = "time") LocalDate time
    org.springframework.core.convert.converter.Converter<String,LocalDateTime>
    解决 @RequestParam(value = "time") LocalDateTime time
    org.springframework.core.convert.converter.Converter<String,LocalTime>
    解决 @RequestParam(value = "time") LocalTime time

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • 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" 8. BaseEnum -> {"code": "xxx", "desc": "xxx"}

      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 - 构造器
      返回:
      全局 ObjectMapper
    • dateConvert

      @Bean public org.springframework.core.convert.converter.Converter<String,Date> 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 - 上下文