赞
踩
前因后果:
前两天在写一个简单页面的时候,前端通过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]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。