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 ?
The Spring Boot framework provides the default embedded server (Tomcat) to run the Spring Boot application. It runs on port 8080. It is possible to change the port in Spring Boot.
Another way to change the port of embedded tomcat in the Spring Boot application is by specifying the server. port property in the resource file. For example, if you want your Spring boot application to listen on port 8080, then you can specify server. port=8080 on the application.
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 {
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With