How can I deploy a WAR in an embedded Jetty 8?

半城伤御伤魂 提交于 2019-12-09 05:40:51

问题


With the following code, how can I deploy a WAR application located on the classpath ?

private Server s; 

@BeforeClass
public static void setUp() throws Exception {
    // Start http server
    Random r = new Random();
    int port = 1024 + r.nextInt(8976);
    s = new Server(new InetSocketAddress("127.0.0.1", port));

    // Add my WAR for deployment here ...

    s.start();
}

Jetty 8.0.1
JDK 6


回答1:


Something like

    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath("/");
    webapp.setWar(warURL);
    server.setHandler(webapp);

The war does not have to be on the class path.



来源:https://stackoverflow.com/questions/9807291/how-can-i-deploy-a-war-in-an-embedded-jetty-8

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!