Type definition error: [simple type, class xxx.xxx.xxx]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of xxx.xxx.xxx (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
这个错误是因为 Jackson 试图将 JSON 数据反序列化为 XXX类的实例,但是 XXX是一个接口或抽象类,Jackson 不知道应该实例化哪个具体的类。
一种解决方法是创建一个 XXX 的具体实现类,并告诉 Jackson 使用这个类来反序列化 JSON 数据。你可以使用 @JsonDeserialize 注解来实现这个目标。
@JsonDeserialize(as = MyXXX .class)
public interface XXX{
// ...
}
public class MyXXX implements XXX{
// 实现 HistoricProcessInstance 接口的方法
}
我的Github地址,欢迎大家加入我的开源项目,或者(在我的主页联系我)加入你们的开源项目,点点Github-Stars。
\ | 开源项目名称 | 依赖类型 | 版本号 | 描述 |
---|---|---|---|---|
1 | spring-boot-starter-trie | pom | 1.0.0-SNAPSHOT | 特定需求下查询速度远超开源检索工具,innodb下B+树或者ES中倒排索引无法与之比拟. |
2 | spring-boot-starter-trie | jar | 1.0.0-M1 | 提供了基于SpringCloud的服务节点,可以通过Nacos注册中心进行服务发现,实现了树的动态扩容与缩容,以及服务的动态上下线。 |
3 | Data-Provider | pom | 1.0.0-SNAPSHOT | 提供了多种数据源的查询,以及数据的类型同步,作为一个Jar可以依赖在其他服务上动态的提供数据。 |