How to force Spring Boot to use Tomcat server in integration tests?

As Stéphane Nicoll stated here you should define an empty TomcatEmbeddedServletContainerFactory @Bean

Simply adding such bean was not sufficient for me. I got 'multiple beans' exception. As I was adding that to a custom test starter I just had to make sure, it is added before EmbeddedServletContainerAutoConfiguration resolution took place, i.e:

@Configuration
@AutoConfigureBefore(EmbeddedServletContainerAutoConfiguration.class)
public class ForceTomcatAutoConfiguration {

    @Bean
    TomcatEmbeddedServletContainerFactory tomcat() {
         return new TomcatEmbeddedServletContainerFactory();
    }
}

Edit: In Spring Boot 2.0 this works for me:

@Configuration
@AutoConfigureBefore(ServletWebServerFactoryAutoConfiguration.class)
public class ForceTomcatAutoConfiguration {

    @Bean
    TomcatServletWebServerFactory tomcat() {
         return new TomcatServletWebServerFactory();
    }
}