October 2018
Intermediate to advanced
982 pages
23h 29m
English
The reason that this works is because of Spring Boot's autoconfiguration magic. We had to remove the Tomcat dependency from the build file in order to prevent a dependency collision between Tomcat and Jetty. Spring Boot does a conditional scan of the classes in the classpath and depending on what it detects, it determines which servlet container will be used.
If we look in the ServletWebServerFactoryAutoConfiguration class, we will see the following conditional code that checks this:
/**
* Nested configuration if Jetty is being used.
*/
@Configuration
@ConditionalOnClass({ Servlet.class, Server.class, Loader.class})
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT) public static ...Read now
Unlock full access