在Spring Boot应用程序中禁用Spring JMS Auto配置 [英] Disabling Spring JMS Auto configuration in Spring Boot Application

查看:151
本文介绍了在Spring Boot应用程序中禁用Spring JMS Auto配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Spring Boot应用程序中,我配置了MQQueueConnectionFactory的两个不同实例(不同的ID),因为这是应用程序的需要.为此,我添加了ibm客户端jar.

In my spring boot application i configure two different instances of MQQueueConnectionFactory (different id) as it is a need of the application. For that i have added ibm client jars.

我还在代码中添加了spring-jms依赖项,因为我想要JmsTemplate等类.添加此依赖项后,JmsAutoConfiguration在类路径中找到JmsTemplate并尝试配置Bean.在此过程中,它将尝试注入ConnectionFactory类型的bean,这是代码失败的地方,并且我开始收到错误消息.下面是来自JmsAutoConfiguration的代码

I have also added spring-jms dependency in my code as i wanted JmsTemplate etc classes. After adding this dependency, JmsAutoConfiguration finds JmsTemplate in classpath and tries to configure beans. In this process, it tries to inject bean of type ConnectionFactory and this is where the code fails and i start getting the error. Below is the code from JmsAutoConfiguration

@Configuration
@ConditionalOnClass(JmsTemplate.class)
@ConditionalOnBean(ConnectionFactory.class)
@EnableConfigurationProperties(JmsProperties.class)
@Import(JmsAnnotationDrivenConfiguration.class)
public class JmsAutoConfiguration {

    @Autowired
    private JmsProperties properties;

    @Autowired
    private ConnectionFactory connectionFactory;

    @Autowired(required = false)
    private DestinationResolver destinationResolver;

我是否有机会关闭Spring Boot的JmsAutoconfiguration功能?如果不是,那么对此的替代解决方案是什么?

Do i have a facility to switch off JmsAutoconfiguration feature of spring boot by any chance? If not then what is the alternative solution for this?

推荐答案

您可以将要禁用的自动配置添加到SpringBootApplication批注:

You can add the auto configurations, which you want to disable, to the SpringBootApplication annotation:

@SpringBootApplication(exclude = JmsAutoConfiguration.class)

这篇关于在Spring Boot应用程序中禁用Spring JMS Auto配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆