-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJetty.java
More file actions
26 lines (22 loc) · 851 Bytes
/
Copy pathJetty.java
File metadata and controls
26 lines (22 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.caozj.test;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class Jetty {
public static void main(String[] args) throws Exception {
Server server = buildNormalServer(8888, "/simba");
server.start();
}
/**
* 创建用于正常运行调试的Jetty Server, 以src/main/webapp为Web应用目录.
*/
public static Server buildNormalServer(int port, String contextPath) {
Server server = new Server(port);
WebAppContext webContext = new WebAppContext("src/main/webapp", contextPath);
webContext.setClassLoader(Thread.currentThread().getContextClassLoader());
webContext.setConfigurationDiscovered(true);
webContext.setDefaultsDescriptor("./webdefault.xml");
server.setHandler(webContext);
server.setStopAtShutdown(true);
return server;
}
}