【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实际上引入一 ...
随机推荐
- 【CSP】最大的矩形
问题描述 试题编号: 201312-3 试题名称: 最大的矩形 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 在横轴上放了n个相邻的矩形,每个矩形的宽度是1,而第i(1 ≤ ...
- 非原创。使用ajax加载控件
非原创.来自博客园老赵. public class ViewManager<T> where T : System.Web.UI.UserControl { private System. ...
- python三大框架之一flask应用
创建一个python项目 第一步:打开pytharm 第二步:创建pure python 类型的项目 第三步:创建项目完成之后选择之前创建的py3_flack 作为虚拟环境 第四步:路径可以通过在制定 ...
- 【HDOJ3567】【预处理bfs+映射+康拓展开hash】
http://acm.hdu.edu.cn/showproblem.php?pid=3567 Eight II Time Limit: 4000/2000 MS (Java/Others) Me ...
- LG3978 【[TJOI2015]概率论】
前置:卡特兰数 记\(C_n\)为\(n\)个节点的二叉树的个数,\(C_0=1\),对于\(n \geq 1\),取一个根节点,枚举其左子树大小,有 \[C_n=\sum_{i=0}^{n-1}C_ ...
- MACOS-Can't-connect-to-local-MySQL-server-through-socket-'/tmp/mysql.sock'
mac os start mysql fail by "brew services start mysql"you can try : mysql.server start
- nginx日志格式配置
我一向对日志这个东西有些许恐惧,因为在分析日志是需要记住不同服务器日志的格式,就拿提取ip这一项来说,有的服务器日志是在第一列,有的是第二列或则第三列等等.知道今天我才发现,日志格式是可以自定义配置的 ...
- day43 数据库学习egon的博客 视图、触发器、事务、存储过程、函数
一 视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,可以将该结果集当做表来使用. 使用视图我们可以把查询过程中的 ...
- How to get checksum by IAR
- Docker网络解决方案-Flannel(转)
转自https://www.cnblogs.com/kevingrace/p/6859114.html Docker跨主机容器间网络通信实现的工具有Pipework.Flannel.Weave.Ope ...