【springboot】之 解析@EnableWebMvc 、WebMvcConfigurationSupport和WebMvcConfigurationAdapter
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但是没有重写任何方法
所以有以下几种使用方式:
@EnableWebMvc+extends WebMvcConfigurerAdapter,在扩展的类中重写父类的方法即可,这种方式会屏蔽springboot的@EnableAutoConfiguration中的设置
extends WebMvcConfigurationSupport,在扩展的类中重写父类的方法即可,这种方式会屏蔽springboot的@EnableAutoConfiguration中的设置
extends WebMvcConfigurerAdapter,在扩展的类中重写父类的方法即可,这种方式依旧使用springboot的@EnableAutoConfiguration中的设置
具体哪种方法适合,看个人对于项目的需求和要把控的程度
在WebMvcConfigurationSupport(@EnableWebMvc)和@EnableAutoConfiguration这两种方式都有一些默认的设定
而WebMvcConfigurationAdapter则是一个abstract class
改为

@http://blog.csdn.net/pinebud55/article/details/53420481
【springboot】之 解析@EnableWebMvc 、WebMvcConfigurationSupport和WebMvcConfigurationAdapter的更多相关文章
- @EnableWebMvc,WebMvcConfigurationSupport,WebMvcConfigurer和WebMvcConfigurationAdapter区别
@EnableWebMvc是什么 直接看源码,@EnableWebMvc实际上引入一个DelegatingWebMvcConfiguration. @Retention(RetentionPolicy ...
- springboot2.0以后WebMvcConfigurationSupport代替WebMvcConfigurationAdapter
1:WebMvcConfigurationSupport代替WebMvcConfigurationAdapter https://blog.csdn.net/wilsonsong1024/articl ...
- Springboot配置文件解析器
@EnableScheduling @MapperScan(value = "com.****.dao") @EnableTransactionManagement @Enable ...
- 快速创建SpringBoot+SSM解析
此处使用IDEA快速搭建SpringBoot应用,首先用SpringBoot搭建WEB工程: 然后点击Next生成项目,首次生成可能有点慢,下次创建的时候就会快很多,生成后的目录结构如下: 我们更改下 ...
- 记一次 springboot 参数解析 bug调试 HandlerMethodArgumentResolver
情况描述 前端输入框输入中文的横线 -- ,到后台接收时变成了 &madsh;$mdash 正常应该显示成这样: bug调试思路记录 最开始完全没有向调试源码方面想,试了不少方法,都没解决,没 ...
- SpringBoot @Value 解析集合配置
引自:https://jitwxs.cn/d6d760c4.html 一.前言 在日常开发中,经常会遇到需要在配置文件中,存储 List 或是 Map 这种类型的数据.Spring 原生是支持这种数据 ...
- SPringBoot 配置类继承WebMvcConfigurationSupport和实现WebMvcConfigurer的使用
个人习惯使用 实现的方式 public class WebMvcConfiguration implements WebMvcConfigurer {
- spring-boot 注解解析
package com.hllq.quan.controller; import com.hllq.quan.mapper.WeiboUserMapper; import com.hllq.quan. ...
- Spring boot 梳理 -@SpringBootApplication、@EnableAutoConfiguration与(@EnableWebMVC、WebMvcConfigurationSupport,WebMvcConfigurer和WebMvcConfigurationAdapter)
@EnableWebMvc=继承DelegatingWebMvcConfiguration=继承WebMvcConfigurationSupport 直接看源码,@EnableWebMvc实际上引入一 ...
随机推荐
- MySQL篇,第一章:数据库知识1
MySQL 数据库 1 一.MySQL概述 1.什么是数据库 数据库是一个存储数据的仓库 2.哪些公司在用数据库 金融机构.购物网站.游戏网站.论坛网站... ... 3.提供 ...
- [LeetCode&Python] Problem 771: Jewels and Stones
You're given strings J representing the types of stones that are jewels, and S representing the ston ...
- xdoj--1144 (合并模板)--有趣的优先队列(优先队列默认权值最大的数在前面)
我觉得这道题出的很好 区别于“哈夫曼树” 因为事之多合并k个 理论说尽可能多合并. 然后我们看一个简单的例子 4 3 1 2 3 4 ——>6 4——>10 (6+10)=16: 1 2 ...
- LSOF查看linux中文件打开情况
如何查看linux中文件打开情况 前言 我们都知道,在linux下,“一切皆文件”,因此有时候查看文件的打开情况,就显得格外重要,而这里有一个命令能够在这件事上很好的帮助我们-它就是lsof. lin ...
- Chrome程序及数据位置变更到非系统盘
Chrome浏览器在Windows系统上安装过程,没有设置安装位置的步骤,所以默认是安装在C盘的.并且,若Chrome作为主要浏览器使用,随着时间的积累,数据文件会非常多.增加系统盘的负荷. Wind ...
- oracle 11g(64位)datebase 安装流程
软件版本:oracle 11g 64位 datebase(二合一,含client) 系统环境:windows 10 专业版 64位操作系统 1)根据自己的操作系统去官网下载相应的安装程序,oracle ...
- 初始While循环和for循环
While循环 While循环,是一个循环加判断的组合,满足判断条件返回 真(True)开始循环代码块,不满足判断条件返回 假(False)不循环 格式: While 条件: 代码块 注意:在Whil ...
- 深入学习Motan系列(一)——入门及知识zookeeper储备
背景以及说明: 最近逮到个RPC框架,打算深入学习,框架千千万,只有懂得内部原理,才能应对复杂的业务,进行自定义化系统. 这个系列的Motan文章也是自己慢慢摸索的轨迹,将这个过程记录下来,一是提升自 ...
- css与html 与js的基础语法
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Sample_2-23456.a ...
- hotel管理
PS:这个界面