I'm always excited to take on new projects and collaborate with innovative minds.

Email

contact@niteshsynergy.com

Website

https://www.niteshsynergy.com/

javafaq

Spring Boot:

Q1: How do I change the default embedded server (Tomcat) in Spring Boot to Jetty or Undertow?

✔️ A:
Exclude Tomcat from spring-boot-starter-web and add your preferred server like this (for Jetty):

<dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-web</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>
 

Q2: What are Spring Boot Actuator features useful for production?

✔️ A:
Spring Boot Actuator provides:

Enable it with:

<dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
 

And expose endpoints:

management.endpoints.web.exposure.include=health,metrics
 

  • http://localhost:8080/actuator/health – Health status

  • http://localhost:8080/actuator/metrics – All available metrics

  • http://localhost:8080/actuator/metrics/jvm.memory.used – Specific metric

  • Metrics (memory, threads, DB, HTTP requests)

  • Health Checks (DB, disk space, services)

  • Externalized Configuration (app settings via files/env)