Vertx Webroot在Fat Jar中

我正在为Vertx-Web应用程序构建一个胖jar。 我想提供一些静态文件。 我用jarroot文件夹打包了jar文件。 请参阅下面的jar截面截图:

在此处输入图像描述

通过执行以下操作,我能够加载webroot / static / test.html文件:

routingContext.response().sendFile("webroot/static/test.html"); 

但是,我无法让静态处理程序工作。 以下是我的完整代码:

 package com.jdescript; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import io.vertx.core.AbstractVerticle; import io.vertx.core.http.HttpServer; import io.vertx.ext.web.Router; import io.vertx.ext.web.handler.StaticHandler; public class WebVerticle extends AbstractVerticle { private HttpServer httpServer; @Override public void start() throws IOException { httpServer = vertx.createHttpServer(); Router router = Router.router(vertx); router.route("/static/*").handler(StaticHandler.create()); router.route("/test").handler(routingContext -> { routingContext.response().sendFile("webroot/static/test.html"); }); httpServer.requestHandler(router::accept).listen(9999); } } 

在上面的示例中, http:// localhost:9999 / static / test.html将显示“Not Found”,而http:// localhost:9999 / test将呈现test.html。

任何帮助将不胜感激。

Vert.x小组已在https://groups.google.com/forum/?fromgroups#!topic/vertx/yKInZuYcqDE上回答。 我的webroot应该看起来像“webroot / test.html”,而不是“webroot / static / test.html”。