Disabling Spring JMS Auto Configuration in Spring Application Download

In my spring boot application, I am setting up two different instances of MQQueueConnectionFactory (different identifier), as it is needed for the application. For this, I added ibm customer banks.

I also added spring -jms dependency in my code, as I need JmsTemplate classes, etc. After adding this dependency, JmsAutoConfiguration finds the JmsTemplate in the class path and tries to configure beans. In this process, he tries to inject a bean of type ConnectionFactory, and this is where the code does not work, and I start getting an 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; 

Do I have the option to disable the spring boot JmsAutoconfiguration function, if possible? If not, what is the alternative solution for this?

+6
source share
3 answers

You can add the autoconfigurations you want to disable in the SpringBootApplication annotation:

 @SpringBootApplication(exclude = JmsAutoConfiguration.class) 
+10
source

if you want to manage it using properties (in this case application.yml), you can do something like this.

 spring: autoconfigure: exclude: org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration 
+2
source

FYI, use this to disable ActiveMQ

 @SpringBootApplication(exclude = ActiveMQAutoConfiguration.class) 
+1
source

All Articles