1 回答

TA貢獻(xiàn)1846條經(jīng)驗(yàn) 獲得超7個(gè)贊
您需要header precedence在反序列化器中禁用:
/**
* Construct an instance with the provided target type, and
* useHeadersIfPresent with a default {@link ObjectMapper}.
* @param targetType the target type.
* @param useHeadersIfPresent true to use headers if present and fall back to target
* type if not.
* @since 2.2
*/
public JsonDeserializer(Class<? super T> targetType, boolean useHeadersIfPresent) {
useHeadersIfPresent參數(shù)必須配置false為. 這樣inferred,將使用一種類型,并且將忽略標(biāo)頭值。
如果你不使用,你應(yīng)該考慮用類似的邏輯spring-kafka-2.2實(shí)現(xiàn)你自己的: https ://github.com/spring-projects/spring-kafka/blob/master/spring-kafka/src/main/java/org/ springframework/kafka/support/serializer/JsonDeserializer.javaJsonDeserializer
添加回答
舉報(bào)