1 回答
TA贡献1846条经验 获得超7个赞
您需要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参数必须配置false为. 这样inferred,将使用一种类型,并且将忽略标头值。
如果你不使用,你应该考虑用类似的逻辑spring-kafka-2.2实现你自己的: https ://github.com/spring-projects/spring-kafka/blob/master/spring-kafka/src/main/java/org/ springframework/kafka/support/serializer/JsonDeserializer.javaJsonDeserializer
添加回答
举报