import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class MyTestServer {
public static void main(String[] args) throws Exception {
Server server = new Server(port);
String webappDirLocation = "src/main/webapp/";
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
webapp.setResourceBase(webappDirLocation);
server.setHandler(webapp);
server.start();
server.join();
}
}
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-test-webapp</artifactId>
<version>xxx</version>
</dependency>
</dependencies>