Spring / Spring Boot 4 Basics Interview Questions
What is Spring Boot's embedded server and how do you configure it?
Spring Boot 4 ships with embedded web servers that start as part of the application JAR -- no external application server is needed. The supported embedded servers in Boot 4 are Tomcat 11 and Jetty 12.1 (Undertow was removed).
| Server | Starter | Notes |
|---|---|---|
| Tomcat 11 | spring-boot-starter-webmvc (default) | Default; Servlet 6.1 compatible; most widely used |
| Jetty 12.1 | Exclude Tomcat, add jetty starter | Servlet 6.1 compatible; good for low-memory environments |
| Undertow | REMOVED in Spring Boot 4 | Not compatible with Servlet 6.1 |
# Tomcat (default): no special configuration needed # application.yml Tomcat tuning: server: port: 8080 servlet: context-path: /api tomcat: max-threads: 200 min-spare-threads: 10 connection-timeout: 20s keep-alive-timeout: 60s # Switch from Tomcat to Jetty: <!-- pom.xml --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webmvc</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jetty</artifactId> </dependency> # SSL / HTTPS configuration: server: port: 8443 ssl: enabled: true key-store: classpath:keystore.p12 key-store-password: ${SSL_KEYSTORE_PASSWORD} key-store-type: PKCS12 key-alias: my-app # Virtual threads with Tomcat (Java 21+): spring: threads: virtual: enabled: true # Tomcat automatically uses virtual thread executor
More Related questions...