Spring-Kafka : Issue while deserialising kafka message - class not in a “trusted package”?

前端 未结 1 1238
予麋鹿
予麋鹿 2020-12-20 08:53

I get the below exception because I produce from one project and the consumer consumes from another project. How can I fix this. Obviously the packages are not the same. So

相关标签:
1条回答
  • 2020-12-20 09:24

    You can whitelist your package by changing assessmentAttemptDetailsEntityConsumerFactory() like this:

        @Bean
        public ConsumerFactory<String, AssessmentAttemptDetailsEntity> assessmentAttemptDetailsEntityConsumerFactory() {
                JsonDeserializer<AssessmentAttemptDetailsEntity> 
                deserializer = new JsonDeserializer<>();
                deserializer.addTrustedPackages("com.lte.assessment.assessments");//your package
            return new DefaultKafkaConsumerFactory(config,deserializer);
        }
    
    0 讨论(0)
提交回复
热议问题