是否有任何简单的方法来部署嵌入了 undertow 的 servlet 网络应用程序?
例如,使用jetty,我可以这样部署:
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();
对于 undertow 有类似的方法吗?我在这里看到了一个例子:https://github.com/undertow-io/undertow/blob/master/examples/src/main/java/io/undertow/examples/servlet/ServletServer.java ,但这并不完全是我想要的,它会一个一个地注册 servlet...
最佳答案
暂时没有。
Undertow 只是提供了一个构建器 API,另一个应用程序可以使用它来构建一个 Servlet。这是一个经过深思熟虑的设计选择,因为它赋予了嵌入应用程序对部署的完全控制权。
我们最终可能会在不同的模块中添加对此的支持(很可能是通过从 Wildfly 中删除相关代码),但目前它在优先级列表中并不高。
关于java - 在嵌入式 undertow 中部署 servlets webapp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22307748/