springboot默认格式化日期只需要在application文件中配置

spring.jackson.date-format= yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone= GMT+
spring.jackson.locale= zh_CN

但是,我在配置过程中发现日期格式依然是long类型,也就是日期格式没有生效

经过查看代码发现,我的MvcConfig继承了WebMvcConfigurationSupport

那么这个类到底做什么呢?导致application配置的json格式失效呢?

如下:

在spring-boot+spring mvc 的项目中,有些时候我们需要自己配置一些项目的设置,就会涉及到这三个,那么,他们之间有什么关系呢? 
首先,@EnableWebMvc=WebMvcConfigurationSupport,使用了@EnableWebMvc注解等于扩展了WebMvcConfigurationSupport但是没有重写任何方法

所以有以下几种使用方式:

  1. @EnableWebMvc+extends WebMvcConfigurerAdapter,在扩展的类中重写父类的方法即可,这种方式会屏蔽springboot的@EnableAutoConfiguration中的设置

  2. extends WebMvcConfigurationSupport,在扩展的类中重写父类的方法即可,这种方式会屏蔽springboot的@EnableAutoConfiguration中的设置

  3. extends WebMvcConfigurerAdapter,在扩展的类中重写父类的方法即可,这种方式依旧使用springboot的@EnableAutoConfiguration中的设置

具体哪种方法适合,看个人对于项目的需求和要把控的程度

在WebMvcConfigurationSupport(@EnableWebMvc)和@EnableAutoConfiguration这两种方式都有一些默认的设定 
而WebMvcConfigurationAdapter则是一个abstract class

改为

@http://blog.csdn.net/pinebud55/article/details/53420481

【springboot】之 解析@EnableWebMvc 、WebMvcConfigurationSupport和WebMvcConfigurationAdapter的更多相关文章

  1. @EnableWebMvc,WebMvcConfigurationSupport,WebMvcConfigurer和WebMvcConfigurationAdapter区别

    @EnableWebMvc是什么 直接看源码,@EnableWebMvc实际上引入一个DelegatingWebMvcConfiguration. @Retention(RetentionPolicy ...

  2. springboot2.0以后WebMvcConfigurationSupport代替WebMvcConfigurationAdapter

    1:WebMvcConfigurationSupport代替WebMvcConfigurationAdapter https://blog.csdn.net/wilsonsong1024/articl ...

  3. Springboot配置文件解析器

    @EnableScheduling @MapperScan(value = "com.****.dao") @EnableTransactionManagement @Enable ...

  4. 快速创建SpringBoot+SSM解析

    此处使用IDEA快速搭建SpringBoot应用,首先用SpringBoot搭建WEB工程: 然后点击Next生成项目,首次生成可能有点慢,下次创建的时候就会快很多,生成后的目录结构如下: 我们更改下 ...

  5. 记一次 springboot 参数解析 bug调试 HandlerMethodArgumentResolver

    情况描述 前端输入框输入中文的横线 -- ,到后台接收时变成了 &madsh;$mdash 正常应该显示成这样: bug调试思路记录 最开始完全没有向调试源码方面想,试了不少方法,都没解决,没 ...

  6. SpringBoot @Value 解析集合配置

    引自:https://jitwxs.cn/d6d760c4.html 一.前言 在日常开发中,经常会遇到需要在配置文件中,存储 List 或是 Map 这种类型的数据.Spring 原生是支持这种数据 ...

  7. SPringBoot 配置类继承WebMvcConfigurationSupport和实现WebMvcConfigurer的使用

    个人习惯使用  实现的方式 public class WebMvcConfiguration implements WebMvcConfigurer {

  8. spring-boot 注解解析

    package com.hllq.quan.controller; import com.hllq.quan.mapper.WeiboUserMapper; import com.hllq.quan. ...

  9. Spring boot 梳理 -@SpringBootApplication、@EnableAutoConfiguration与(@EnableWebMVC、WebMvcConfigurationSupport,WebMvcConfigurer和WebMvcConfigurationAdapter)

    @EnableWebMvc=继承DelegatingWebMvcConfiguration=继承WebMvcConfigurationSupport 直接看源码,@EnableWebMvc实际上引入一 ...

随机推荐

  1. tumblr热度

  2. Plant(𝐶𝑜𝑑𝑒𝐹𝑜𝑟𝑐𝑒𝑠 − 185𝐴)

    #include<iostream> #include<cstring> using namespace std; ,mod=; struct Matrix { long lo ...

  3. #include<bits/stdc++.h>的使用

    #include<bits/stdc++.h>包含了C++里面所有的库函数,因此在写任何程序的时候只需要加上#include<bits/stdc++.h>即可.

  4. 《DSP using MATLAB》Problem 7.1

    只有春节那么几天才能和家人团聚,看着爸爸妈妈一年比一年老,自己还是一无所有,照顾好自己尚且惭愧,真是悲从中来,又能怎么办呢, 唯有奋发努力,时不我待,多想想怎么赚钱,加油. 代码: function ...

  5. Spring 中的接口知识整理

    本想每个小知识一篇随笔,但是那样,看起来有些单薄,所以,就放在一片文章里了.而且,以后还会慢慢在最后不断的追加. 目录: FactoryBean BeanPostProcessor 1.Factory ...

  6. eclipse svn不能忽略文件及文件夹,ignore设置无效 ?

    https://blog.csdn.net/zengmingen/article/details/79025445 https://blog.csdn.net/zengmingen/article/d ...

  7. DevExpress的DateEdit控件正确显示日期的周名称

    DevExpress 的控件相当好看而且很好用,但 DateEdit 在是显示周名时,只能显示一个“星”字. 以下是解决方法,此解决方法不需修改其源码,所以免去了重新编译的必要,可直接使用其发布的标准 ...

  8. IBM websphere MQ使用说明

    百度文库: IBM websphere MQ使用说明 IBM MQ安装和配置

  9. oracle-sql优化器

    优化器optimizer Oracle 执行计划(Explain Plan) 说明 http://langgufu.iteye.com/blog/2158163 explain plan是一个dml语 ...

  10. ~ # himm -sh: himm: not found的解决方法

    ls /bin发现没有himm 海思根文件默认没有把himm工具集成在bin里,但是在sdk中 /home/swann/Hi3516CV300_SDK_V1.0.3.0/osdrv/tools/boa ...