Skip to content

Instantly share code, notes, and snippets.

@digvijaybhakuni
Created January 10, 2017 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digvijaybhakuni/ef8b867ddfd8c970177d2300e67d6426 to your computer and use it in GitHub Desktop.
Save digvijaybhakuni/ef8b867ddfd8c970177d2300e67d6426 to your computer and use it in GitHub Desktop.
Create Jetty Server Minimal
group 'com.dgstack.eg'
version '1.0'
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'application'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.3.15.v20161220'
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.3.15.v20161220'
}
task runApp(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'com.dgstack.eg.JettyServer'
}
package com.dgstack.eg;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class JettyServer {
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
WebAppContext context = new WebAppContext();
context.setContextPath("/");
context.setDescriptor("src/main/webapp/web.xml");
context.setResourceBase("src/main/webapp/");
server.setHandler(context);
server.start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment