Hard java spring

7. How does Spring Boot detect embedded Tomcat automatically?

Sample answer: "The web starter puts Tomcat classes on the classpath. The servlet web server auto-configuration has a condition on Tomcat's classes, so it creates a Tomcat web server factory, and the context starts Tomcat during refresh. If I swap the dependency for Jetty, the Jetty condition matches instead." Editor's note: the class-level detail comes from the source code, not the docs.

Sources (2)
  1. Servlet web applications: Embedded servlet container support
  2. Condition annotations