title: Spring Boot 1.5.4: exclude configuration class in unit test
body: <p>I have a Spring Boot project, version 1.5.4, with a MongoDb configuration class:</p>
  
  <pre><code>@Configuration
  public class MongoConfig {
  
  @Value("${spring.data.mongo.client.uri:mongodb://localhost:27017/database}")
  private String mongoURI;
  
  @Bean
  public MongoDbFactory mongoFactory() throws UnknownHostException{
      return new SimpleMongoDbFactory(new MongoClientURI(mongoURI));
  }
  
  @Bean
  public MongoTemplate mongoTemplate() throws UnknownHostException, MongoException{
      return new MongoTemplate(mongoFactory());
  }
  }
  </code></pre>
  
  <p>In my integration test i want use <em>Embedded Mongo</em> (<a href="https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo" rel="nofollow noreferrer">https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo</a>).</p>
  
  <p>The problem is that the MongoDb configuration class start before the initialitation of Embedded mongo and try to connect to the database, so my test fail. If i remove the <em>MongoConfig</em> class, all test work well.</p>
  
  <p>How can i exclude it only in my test execution?</p>