Deploying servlets webapp in embedded undertow

耗尽温柔 提交于 2021-02-06 11:26:10

问题


Is there any easy way to deploy a servlets web application with undertow embbeded?

For example, with jetty, I can deploy like this:

    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();

Is there a similar way of doing this with undertow? I saw a example here: https://github.com/undertow-io/undertow/blob/master/examples/src/main/java/io/undertow/examples/servlet/ServletServer.java, but it's not exaclty what I want, it registers the servlets one by one...


回答1:


Not at the moment.

Undertow just provides a builder API, that another application can use to build up a Servlet. This was a deliberate design choice as it gives the embedding application full control of the deployment.

We may eventually add support for this in a different module (most likely by ripping the relevant code out of Wildfly), but it is not high on the priority list at the moment.




回答2:


I think the new wildfly swarm project provides a good workaround for that as you can deploy any webapp just with the undertow module picked from wildfly and packaged in a single fat jar. A good example is here: https://github.com/wildfly-swarm/wildfly-swarm-examples/tree/master/servlet



来源:https://stackoverflow.com/questions/22307748/deploying-servlets-webapp-in-embedded-undertow

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