Caused by: java.lang.SecurityException: Attempt to deserialize unauthorized class cn.seczone.sscsp.common.model.TaskSbomMessageMq; add allowed class name patterns to the message converter or, if you trust the message orginiator, set environment variable ‘SPRING_AMQP_DESERIALIZATION_TRUST_ALL’ or system property ‘spring.amqp.deserialization.trust.all’ to true
颠末查博客和gpt终极得到几个结果
方案一:
在设置文件设置信托的类
spring:
rabbitmq:
listener:
simple:
allowed-classes:
- cn.baidu.kkscsp.common.mq.TaskSbomMessageMq
- cn.baidu.kkscsp.common.mq.TaskMessageMq
复制代码
方案二:
自界说一下一个消息转换的bean,并在此中设置信托的包,即实体类的路径
生产者:
public class RabbitMQConfig {
@Bean
public MessageConverter jsonToMapMessageConverter() {
DefaultClassMapper defaultClassMapper = new DefaultClassMapper();