DIGITAL GURU
Java DSA Portfolio

Embedded Eclipse Jetty

Switch Spring Boot embedded web server from Apache Tomcat to Eclipse Jetty or Netty for lightweight execution.

Anuj Kumar Singh Written by Anuj Kumar Singh (Lead Engineer, 13+ yrs exp) 5 min read Verified Spring Boot 3+ Guide

Real-World Analogy

Switching to Jetty is like swapping out a standard commercial delivery van for an ultra-lightweight electric scooter—ideal for high-concurrency low-memory microservices.

Replacing Tomcat with Jetty

Eclipse Jetty is an ultra-lightweight alternative to Tomcat. To use Jetty, exclude `spring-boot-starter-tomcat` and add `spring-boot-starter-jetty`.

Production Code Example:

pom.xml
<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>

Key Architectural Concepts & Best Practices:

When working with Embedded Eclipse Jetty in enterprise Spring Boot applications, keep these key architectural guidelines in mind:

  • Separation of Concerns: Maintain a strict boundary between HTTP endpoints, service logic, and database persistence layers.
  • Framework Conventions: Rely on Spring Boot auto-configuration defaults whenever possible, overriding settings only via application.yml or @Configuration classes when customized behavior is required.
  • Production Monitoring & Reliability: Ensure proper exception handling, thread-safety, and resource cleanup to prevent memory leaks and unexpected runtime downtime.
  • Developer Ergonomics: Write clean, self-documenting code with modern Java features (Records, Lambdas, Streams) to simplify code reviews and maintenance.

Summary Takeaway:

Mastering Embedded Eclipse Jetty ensures that your Java & Spring Boot backend microservices remain maintainable, secure, and compliant with modern enterprise software engineering standards.

Use Case

Jetty is popular in low-footprint containerized microservice deployments.