1

I have a class called LogRabbitConfig like this in package com.balabala.soa.misc.config:

@Configuration
@Slf4j
public class LogRabbitConfig {

  @Bean(name = "reportConnectionFactory")
  public ConnectionFactory firstConnectionFactory(
        @Value("${rabbitmq.server.report.host}") String host,
        @Value("${rabbitmq.server.report.port}") int port,
        @Value("${rabbitmq.server.report.username}") String username,
        @Value("${rabbitmq.server.report.password}") String password,
        @Value("${rabbitmq.server.report.virtual.hostname}") String virtualHost)
   {
      CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
      connectionFactory.setHost(host);
      connectionFactory.setPort(port);
      connectionFactory.setUsername(username);
      connectionFactory.setPassword(password);
      connectionFactory.setVirtualHost(virtualHost);
      connectionFactory.setPublisherConfirms(true);
      connectionFactory.setPublisherReturns(true);
      connectionFactory.setConnectionTimeout(2000);
      return connectionFactory;
   }
}

This package will be scanned by default in spring boot project. But in some projects, I did not want this class be scanned. What should I do to excude this single class? Is it possible to exclude this class by spring component scan?

ouflak
  • 2,458
  • 10
  • 44
  • 49
Dolphin
  • 29,069
  • 61
  • 260
  • 539

0 Answers0