BeanInstantiationException: Failed to instantiate [java.time.LocalDateTime]
错误提示:
Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.time.LocalDateTime]: No default constructor found; nested exception is java.lang.NoSuchMethodException: java.time.LocalDateTime.<init>()
DTO中包含LocalDateTime.如果有此类型的字段.基本就是400.转化失败.
因为他要求字符串的格式里面有T.就是2017-05-17T12:45:00 这种的.没什么卵用.
于是上网百度.2种办法.1.自定义参数解析器.终极大招.2.是注册转换服务.比较轻巧.就几句代码.也简单.对常用的几种格式进行了转换.
org.springframework.format.support.FormattingConversionServiceFactoryBean
一开始没什么问题.DTO种包含LocalDateTime.成功转换.
但是今天直接用LocalDateTime做参数就报上面那个错误.错误原因很简单.要new一个对象.但是LocalDateTime.不能new.上网也百度了好久.没找到什么好办法.关键是没几个遇到并且提问.....就差使用终极大招了.
最后想了想.他不是要new嘛.
@RequestParam(required = false)
把必须设成false.看行不行.结果瞎猫碰上死耗子.成了.它没有去new对象去.于是就进行到了自定义转换那一步.也就成了.
BeanUtils.instantiateClass()
吐槽一下这个方法.你说自定义的类不能new你报错就算了.这种java自带的也不特殊判断一下.真是日了狗了.....我也没找到什么重写之类的方法.
BeanInstantiationException: Failed to instantiate [java.time.LocalDateTime]的更多相关文章
- 【spring mvc】后台spring mvc接收List参数报错如下:org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface
后台spring mvc接收List参数报错如下:org.springframework.beans.BeanInstantiationException: Failed to instantiate ...
- Failed to instantiate [java.util.List]: Specified class is an interface
错误信息提示: Failed to instantiate [java.util.List]: Specified class is an interface; 错误信息意思:参数错误,参数封装出了问 ...
- org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.jboss.resteasy.plug
之前做的项目是resteasy的上传,代码没有问题,断点都不进来呢. 我以为可以直接移植到SpringMVC,但是SpringMVC不支持MultipartFormDataInput , 用Multi ...
- Spring使用mutipartFile上传文件报错【Failed to instantiate [org.springframework.web.multipart.MultipartFile]】
报错场景: 使用SSM框架实现文件上传时报“Failed to instantiate [org.springframework.web.multipart.MultipartFile]”错,控制器源 ...
- Failed to instantiate [org.elasticsearch.client.transport.TransportClient]
Springboot 集成 ElasticSearch,springboot报错如下: Error starting ApplicationContext. To display the auto-c ...
- 解决Redisson出现Failed to instantiate [org.redisson.api.RedissonClient]: Factory method 'create' threw exception; nested exception is java.lang.ArrayIndexOutOfBoundsException: 0的问题
一.背景 最近项目中使用了redisson的哨兵模式来作为redis操作的客户端,然后一个意外出现了,启动报:Failed to instantiate [org.redisson.api.Redis ...
- org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.hs.model.StudentModel]: No default constructor found; nested exception is java.lang.NoSuchMethodException: c
root cause org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [c ...
- org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.util.List]: Specified class
错误:org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.util ...
- springmvc上传文件报错org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.multipart.MultipartFile]
在用springmvc+mybatis进行项目开发时,上传文件抛异常... org.springframework.beans.BeanInstantiationException: Could no ...
随机推荐
- Python之路-awk文本处理
作业一:整理博客,内容包含awk.变量.运算符.if多分支 一.awk 1.awk是一个优秀的文本处理工具,多用来处理含有特殊分隔符的内容 常见用法 awk -F: {print $1,$4} 作业 ...
- 老李分享:《Linux Shell脚本攻略》 要点(二)
老李分享:<Linux Shell脚本攻略> 要点(二) poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课 ...
- Java类修饰符
- DynamicObject扩展--实现JSON和DynamicObject的序列化与反序列化
度娘许久,找不到我满意的答案,于是自己东凑西凑实现一个. DynamicObject扩展--实现JSON和DynamicObject的序列化与反序列化,亲测良好. 看代码 using System; ...
- Kubernetes DNS 简介
环境 $ sudo lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16 ...
- (读书笔记)函数参数浅析-JavaScript高级程序设计(第3版)
ECMAScript函数不介意传递的参数个数,因为在其内部是用一个数组进行表示的.在函数体内可以通过arguments对象来访问这个参数数组,就像我们正常访问数组一样处理. arguments对象只是 ...
- Vxlan与网卡offload性能
背景 由于数据链路层MTU的限制,发送端TCP/UDP数据在交付到IP层时需要与MTU相匹配,TCP数据不能超过mss,较长的UDP需要分片(Fragmentation)以满足MTU要求:接收端协议栈 ...
- Spring+Redis(keyspace notification)实现定时任务(订单过期自动关闭)
1.起因 最近公司项目要做订单超期未支付需自动关闭,首先想到的是用spring的定时器(@Schedule),结果领导举各种例子说会影响性能,只能作罢.后来想能不能基于redis实现, 学习(baid ...
- 《Python自然语言处理》第二章-习题解答-练习6
问题描述:在比较词表的讨论中,创建一个对象叫做translate,通过它你可以使用德语和意大利语词汇查找对应的英语词汇.这种方法可能会出现什么问题,你能提出一个办法来避免这个问题吗? 虽然这是一道初级 ...
- linux入门之用户管理
用户管理 添加用户 以root用户执行 adduser 或 useradd [new_account] -u UID -d 指定家目录 -g GID 指定一个基本组ID -G指定一个附加组 ...