How Spring Boot Integrates Embedded Tomcat to Power Your Java Web Apps
Spring Boot simplifies Java web development by embedding Tomcat as its default servlet container, automatically configuring components like Engine, Host, Context, Wrapper, and Connector through application properties, while supporting dynamic servlet registration, WAR deployment, and revealing the underlying initialization process via logs and code.
In recent years Spring Boot has become popular because it reduces the cumbersome configuration of traditional Spring and, together with Spring Cloud, enables rapid development of Java web applications.
Spring Boot starts a web service as a standard Java application and hides the servlet container configuration inside a properties file; Tomcat is one of the built‑in containers used for this purpose.
The integration works similarly to classic Tomcat configuration: most settings have sensible defaults, while user‑specific options are read from application.properties (or application.yml) and applied to Tomcat’s components.
Spring Boot actually supports three embedded containers—Tomcat, Jetty, and Undertow—with Tomcat being the default one.
s.b.c.e.t.TomcatEmbeddedServletContainer: Tomcat initialized with port
This log line, produced by Logback, shows the abbreviated package name and the TomcatEmbeddedServletContainer that Spring Boot creates.
The container’s init method triggers the start of the embedded Tomcat instance:
this.tomcat.start();
During startup Tomcat builds several core components:
Engine
Host
Context
Wrapper
Connector
The first four form a hierarchical relationship inside the container, while the Connector links the container to the outside world, making the deployed application reachable.
When the start step is reached, all component configurations have already been completed; the container simply begins to serve requests.
Spring MVC processes requests via DispatcherServlet . Before Spring Boot, this servlet had to be declared in web.xml. Since Servlet 3.0, dynamic registration of servlets and filters is possible, allowing the container to add them to the Context at runtime.
Besides running as an executable JAR with an embedded container, Spring Boot can also be packaged as a WAR and deployed to a standard servlet container, where it relies on the META-INF/services directory.
During container startup, the servlet container scans for implementations of ServletContainerInitializer (SCI) annotated with @HandlesTypes. Each initializer’s onStartup method receives the discovered classes, allowing Spring Boot’s initializer to register the DispatcherServlet and other components just as when the application is launched via its main method.
Thus, even though Spring Boot hides much of the configuration, the embedded Tomcat still performs substantial work behind the scenes, adhering to modern J2EE specifications while providing a streamlined development experience.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
