SpringBoot + ActiveMQ - 如何设置可信包?
2022-09-02 14:26:18
我正在创建两个使用JMS进行通信的springboot服务器和客户端应用程序,并且activemq的发布一切正常,但是一旦我更新到该版本,我就收到以下错误:5.12.1
5.12.3
org.springframework.jms.support.converter.MessageConversionException: Could not convert JMS message; nested exception is javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class MyClass! This class is not trusted to be serialized as ObjectMessage payload. Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes.
我访问了提供的URL,我发现我的问题与ActiveMQ版本中实现的新安全性有关,并且我知道我可以通过定义受信任的包来修复它,但是我不知道在我的SpringBoot项目中放置这样的配置的位置。5.12.2
我对我的客户端和服务器中的 JMS 队列所做的唯一引用是在 application.properties 中设置它的 URI,并在我的“main”类上启用 JMS,下面是我在单独代理上的配置:@EnableJms
@Configuration
@ConfigurationProperties(prefix = "activemq")
public class BrokerConfiguration {
/**
* Defaults to TCP 10000
*/
private String connectorURI = "tcp://0.0.0.0:10000";
private String kahaDBDataDir = "../../data/activemq";
public String getConnectorURI() {
return connectorURI;
}
public void setConnectorURI(String connectorURI) {
this.connectorURI = connectorURI;
}
public String getKahaDBDataDir() {
return kahaDBDataDir;
}
public void setKahaDBDataDir(String kahaDBDataDir) {
this.kahaDBDataDir = kahaDBDataDir;
}
@Bean(initMethod = "start", destroyMethod = "stop")
public BrokerService broker() throws Exception {
KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter();
persistenceAdapter.setDirectory(new File(kahaDBDataDir));
final BrokerService broker = new BrokerService();
broker.addConnector(getConnectorURI());
broker.setPersistent(true);
broker.setPersistenceAdapter(persistenceAdapter);
broker.setShutdownHooks(Collections.<Runnable> singletonList(new SpringContextHook()));
broker.setUseJmx(false);
final ManagementContext managementContext = new ManagementContext();
managementContext.setCreateConnector(true);
broker.setManagementContext(managementContext);
return broker;
}
}
所以我想知道我应该在哪里指定受信任的包。
谢谢:)