这是我的方法,其中有这个错误
private <T> Mono<CarbonResponse<T>> evaluateVersion(Key key, String facts, boolean showTestResults) {
return mapper.readValue(result, new TypeReference<CarbonResponse<T>>() {}); // error here
}
其中,result是JSON字符串。
我的CarbonResponse.java
public class CarbonResponse<T> {
int code;
String message;
DataV1<T> data;
}
DataV1.java
public class DataV1<T> {
@JsonProperty(value = "rule_set_id")
String ruleSetId;
@JsonProperty(value = "version_id")
String ruleSetVersionId;
T result;
@JsonProperty(value = "rules_evaluation_response")
List<T> rulesEvaluationResponse;
}
平地机
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.10.3'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.10.3'
完整错误轨迹
java.lang.IllegalArgumentException: Unrecognized Type: [null]
at com.fasterxml.jackson.databind.type.TypeFactory._fromAny(TypeFactory.java:1266)
at com.fasterxml.jackson.databind.type.TypeFactory._fromParamType(TypeFactory.java:1480)
at com.fasterxml.jackson.databind.type.TypeFactory._fromAny(TypeFactory.java:1250)
at com.fasterxml.jackson.databind.type.TypeFactory.constructType(TypeFactory.java:670)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3197)
at com.pharmeasy.carbon.client.CarbonClient.lambda$evaluateVersion$0(CarbonClient.java:321)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:100)
at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1705)
at reactor.core.publisher.MonoZip$ZipCoordinator.signal(MonoZip.java:247)
at reactor.core.publisher.MonoZip$ZipInner.onNext(MonoZip.java:329)
我能知道我错过了什么吗?
我想当我们有T的时候,这个new TypeReference<CarbonResponse<T>>() {}
会给出null,但是我无法找到解决方案。
1条答案
按热度按时间3zwtqj6y1#
您只需使用