Created
January 10, 2017 09:30
-
-
Save digvijaybhakuni/ef8b867ddfd8c970177d2300e67d6426 to your computer and use it in GitHub Desktop.
Create Jetty Server Minimal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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