Spring Kafka The class is not in the trusted packages

后端 未结 6 1172
北荒
北荒 2020-12-31 03:20

In my Spring Boot/Kafka application before the library update, I used the following class org.telegram.telegrambots.api.objects.Update in order to post messages

6条回答
  •  庸人自扰
    2020-12-31 04:02

    See the documentation.

    Starting with version 2.1, type information can be conveyed in record Headers, allowing the handling of multiple types. In addition, the serializer/deserializer can be configured using Kafka properties.

    JsonSerializer.ADD_TYPE_INFO_HEADERS (default true); set to false to disable this feature on the JsonSerializer (sets the addTypeInfo property).

    JsonDeserializer.KEY_DEFAULT_TYPE; fallback type for deserialization of keys if no header information is present.

    JsonDeserializer.VALUE_DEFAULT_TYPE; fallback type for deserialization of values if no header information is present.

    JsonDeserializer.TRUSTED_PACKAGES (default java.util, java.lang); comma-delimited list of package patterns allowed for deserialization; * means deserialize all.

    By default, the serializer will add type information to the headers.

    see the boot documentation.

    Similarly, you can disable the JsonSerializer default behavior of sending type information in headers:

    spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer spring.kafka.producer.properties.spring.json.add.type.headers=false

    Or you can add type mapping to the inbound message converter to map the source type to the destination type.

    EDIT

    Having said that, what version are you using?

提交回复
热议问题