【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实际上引入一 ...
随机推荐
- dfs——n的全排列(回溯)
#include <iostream> #include <cstring> #include <string> #include <map> #inc ...
- java实现各种排序算法
java实现各种排序算法 import java.util.Arrays; public class SomeSort { public static void main(String[] args) ...
- (23)ajax实现上传文件的功能
form表单上传文件 urls.py from django.conf.urls import urlfrom django.contrib import adminfrom app01 import ...
- YIT-CTF—密码学
一.哼哼 小猪生活的地方在哪里? 看题目联想到是猪圈加密 二.卢本伟 LOL我只服五五开 ๑乛◡乛๑babbababaababbababaaababaaaaaaabaaa 更具提示“五五开”,再看到这 ...
- Windows下安装Python模块时环境配置
“Win +R”打开cmd终端,如果直接在里面使用pip命令的时候,要么出现“syntax invalid”,要么出现: 'pip' is not recognized as an internal ...
- String的方法capitalize
官方解释:Return a copy of the string with its first character capitalized and the rest lowercased.(返回字符串 ...
- 在Java中,以下关于方法重载和方法重写描述正确的是?
public class TTTTT extends SuperC{ public String get(){ return null; } } class SuperC{ Object get(){ ...
- Centos7提示swap交换空间不足解决方法
一张图就能解决的问题,就不多bb了
- Roll a ball 学习
using UnityEngine; using System.Collections; /// <summary> /// 相机控制 /// </summary> publi ...
- IBM WebSphere MQ介绍安装以及配置服务详解
首先介绍一下MQ MQ消息队列的简称是一种应用程序对应用程序的通信方法.说白了也就是通过队列的方式来对应用程序进行数据通信.而无需专用链接来链接它们. MQ的通讯方式 1.数据报的方式 Datagra ...