In a Spring Boot application, you can use different embedded servers as the underlying servlet container to run your application. By default, Spring Boot uses Apache Tomcat as the embedded servlet container, but it also supports other options. Here are the commonly used embedded servers in a Spring Boot application:
- Tomcat: Apache Tomcat is the default embedded servlet container used by Spring Boot. It is a widely used servlet container known for its simplicity, reliability, and performance. Tomcat provides support for the Java Servlet, JavaServer Pages (JSP), and WebSocket specifications.
- Jetty: Jetty is another popular embedded servlet container supported by Spring Boot. It is known for its lightweight and fast startup time, making it suitable for applications with strict performance requirements. Jetty provides support for Servlet, JSP, WebSocket, and HTTP/2 protocols.
- Undertow: Undertow is a lightweight and high-performance web server developed by the JBoss community. It is known for its asynchronous and non-blocking I/O capabilities, making it suitable for applications with high concurrency requirements. Undertow provides support for Servlet, WebSocket, and HTTP/2 protocols.
- Netty (Less common): Although less commonly used, Spring Boot also supports Netty as an embedded server. Netty is a high-performance network application framework written in Java, known for its asynchronous and event-driven architecture. It is often used for building high-performance, low-latency applications such as networking servers and proxies.
To configure Spring Boot to use a specific embedded server, you can exclude the default embedded container dependency (Tomcat) and include the dependency for the desired embedded server in your project's pom.xml
or build.gradle
file. Additionally, you can customize various aspects of the embedded server, such as port configuration, SSL/TLS settings, and performance optimizations, using configuration properties in the application.properties
or application.yml
file.