I use default Tomcat embedded container. However, in some of my tests I use Wiremock (using Jetty underneath). This makes my integration tests run against Jetty server, not Tomcat.
Is there any way to force Spring Boot to stick with Tomcat ?
I use default Tomcat embedded container. However, in some of my tests I use Wiremock (using Jetty underneath). This makes my integration tests run against Jetty server, not Tomcat.
Is there any way to force Spring Boot to stick with Tomcat ?
With Spring Boot 2.3 the above solution hasn't worked for me.
Perhaps I have special circumstances with not having a SpringBootApplication in the main classes. I have only a SpringBootApplication in the test classes.
Anyhow this has worked for me:
@SpringBootApplication(exclude = org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration.class)
public class TestApplication {
}
with Spring Boot 2.5.10
@AutoConfigureBefore(ServletWebServerFactoryAutoConfiguration.class)
didn't work for me.
but as sven doring mentioned excluding EmbeddedWebServerFactoryCustomizerAutoConfiguration worked for me.
it even worked for external tomcat
code is below
@SpringBootApplication(exclude = org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration.class)