As Stefan Nicholl said here , you must define emptyTomcatEmbeddedServletContainerFactory @Bean
Just adding such a bean was not enough for me. I got a "multiple exception beans". Since I was adding this to my own test starter, I just had to make sure it was added before resolution EmbeddedServletContainerAutoConfiguration, 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();
}
}
source
share