当前位置:   article > 正文

解决:cannot deserialize from Object value (no delegate- or property-based Creator)

cannot deserialize from object value

解决:cannot deserialize from Object value (no delegate- or property-based Creator)

前因后果:
前两天在写一个简单页面的时候,前端通过ajax请求发送参数,后端创建了一个实体类用来接收参数,这个实体类添加了Lombok的@Data注解,没有创建其他构造函数,当前端发送请求时后端控制台就会抛出以下异常,后经过查询发现原来是因为实体类没有无参构造函数造成的。

解决方式:
手动创建一个无参构造器或者添加Lombok注解@NoArgsConstructor即可。

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class com.thunisoft.commons.cryptoonline.bean.ParamBean]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.thunisoft.commons.cryptoonline.bean.ParamBean` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: (PushbackInputStream); line: 1, column: 2]] with root cause

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.thunisoft.commons.cryptoonline.bean.ParamBean` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: (PushbackInputStream); line: 1, column: 2]
  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/896795
推荐阅读
相关标签
  

闽ICP备14008679号