Jetty Local Development Guide

Run Java Web applications on localhost using Eclipse Jetty, default port 8080, a lightweight embedded Servlet container.


Eclipse Jetty is a lightweight Java Servlet container that can run independently or be embedded within applications. It is commonly integrated with Spring Boot and Maven plugins, making it suitable for local development and testing of Java Web applications.

Default localhost Access

PurposeAddress
Standalonehttp://localhost:8080
Spring Boothttp://localhost:8080 (can change server.port)

Usage

Maven Jetty Plugin

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>11.0.20</version>
</plugin>
mvn jetty:run

Access in your browser at http://localhost:8080.

Spring Boot

server.port=8080

After running the jar or spring-boot:run, access http://localhost:8080.

Comparison with Tomcat

Jetty starts faster, has a smaller footprint, and is more friendly for embedding; Tomcat is more commonly found in full Java EE deployments. Both typically use 8080 as the default localhost port.

Frequently Asked Questions

Port 8080 is Occupied
Change the server.port or the port in the Jetty plugin configuration.

Class Loading / Version Conflicts
Be aware of the correspondence between the Servlet API and the main version of Jetty (Jetty 11 corresponds to Jakarta Servlet 5).

Conclusion

Jetty is suitable for embedded and Maven local development, allowing access to Java Web applications via http://localhost:8080.

访客计数:------ Best viewed in Netscape Navigator · 800×600 © LocalHost Run