Commit 28054c7d authored by neo's avatar neo

[DEV] add local jetty run to run fast

parent 73da29b8
......@@ -316,6 +316,19 @@
<artifactId>guava</artifactId>
<version>24.0-jre</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty.aggregate/jetty-all -->
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty.aggregate/jetty-all -->
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all</artifactId>
<version>9.4.10.v20180503</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<version>9.4.10.v20180503</version>
</dependency>
</dependencies>
<profiles>
......
package pwc.taxtech.atms;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
public class JettyLauncher {
public static void main(String[] args) {
int port = 8180;
Server server = new Server(port);
WebAppContext webAppContext = new WebAppContext("webapp", "/");
webAppContext.setDescriptor("webapp/WEB-INF/web.xml");
webAppContext.setResourceBase("src/main/webapp");
webAppContext.setDisplayName("atms-api");
webAppContext.setClassLoader(Thread.currentThread().getContextClassLoader());
webAppContext.setConfigurationDiscovered(true);
webAppContext.setParentLoaderPriority(true);
server.setHandler(webAppContext);
System.out.println(webAppContext.getContextPath());
System.out.println(webAppContext.getDescriptor());
System.out.println(webAppContext.getResourceBase());
System.out.println(webAppContext.getBaseResource());
try {
ServerContainer wscontainer = WebSocketServerContainerInitializer.configureContext(webAppContext);
// Add WebSocket endpoint to javax.websocket layer
// wscontainer.addEndpoint(MyWebSocket.class); //这行是如果需要使用websocket就加上,不需要就注释掉这行,mywebsocket是自己写的websocket服务类
server.start();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("server is start, port is " + port + "............");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment