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.cyj.cloudcommon.utils.api.R]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException:
Cannot construct instance of `com.cyj.cloudcommon.utils.api.R` (no Creators, like default construct, 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.cyj.cloudcommon.utils.api.R` (no Creators, like default construct, exist):
cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (PushbackInputStream); line: 1, column: 2]
使用jackson对json字符串转对象时报错:
Cannot construct instance of com.cyj.cloudcommon.utils.api.R
(no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator) at [Source: (PushbackInputStream); line: 1, column: 2]
com.cyj.cloudcommon.utils.api.R
代码中自定义了有参数的构造函数,导致默认无参构造函数失效,需要手动添加无参构造函数,用于对象的json序列化。
为 com.cyj.cloudcommon.utils.api.R
添加默认构造函数
public R() {
}