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
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
