@ApplicationPath注释IS不拿到#3140

发布于 2025-02-13 19:45:17 字数 2481 浏览 0 评论 0原文

我正在尝试将Vert.x应用程序与Resteasy一起整理。当应用程序加载并启动服务器时。我期望/v1/health可以正常工作,但它只是抛出404

main.java

public class Main extends AbstractVerticle {
    private static VertxResteasyDeployment deployment;

    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();

        deployment = new VertxResteasyDeployment();
        deployment.setApplicationClass("starter.rx.endpoint.V1");
        deployment.start();
        vertx.deployVerticle("starter.rx.Main");
    }

    @Override
    public Completable rxStart() {
        VertxRequestHandler handler = new VertxRequestHandler(vertx.getDelegate(), deployment);

        return vertx.createHttpServer()
                .requestHandler(x -> handler.handle(x.getDelegate()))
                .rxListen(80)
                .ignoreElement();
    }
}

v1.java

@ApplicationPath("v1")
public class V1 extends Application {
    private final Set<Object> singletons = new HashSet<>();

    public V1() {
        singletons.add(new Management());
    }

    @Override
    public Set<Object> getSingletons() {
        return singletons;
    }
}

Management.java

@Path("")
public class Management {
    @GET
    @Path("health")
    public CompletionStage<String> health() {
        return Flowable.just("healthy").singleStage("");
    }
}

logs

22:48:47.658 [main] INFO  o.jboss.resteasy.resteasy_jaxrs.i18n -
                RESTEASY002225: Deploying jakarta.ws.rs.core.Application: class starter.rx.endpoint.V1
22:48:47.662 [main] INFO  o.jboss.resteasy.resteasy_jaxrs.i18n -
                RESTEASY002220: Adding singleton resource starter.rx.endpoint.Management from Application class starter.rx.endpoint.V1

输出

$ curl http://localhost:80/health
healthy

$ curl -i http://localhost:80/v1/health
HTTP/1.1 404 Not Found
transfer-encoding: chunked

这些是我正在使用的lib

      "io.vertx" % "vertx-core" % "4.3.1",
      "org.jboss.resteasy" % "resteasy-vertx" % "6.0.1.Final",
      "io.vertx" % "vertx-rx-java3" % "4.3.1",

I'm trying to put together a vert.x application with resteasy. While the application gets loaded and the server starts up. I expected /v1/health to work but it just throws a 404

Main.java

public class Main extends AbstractVerticle {
    private static VertxResteasyDeployment deployment;

    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();

        deployment = new VertxResteasyDeployment();
        deployment.setApplicationClass("starter.rx.endpoint.V1");
        deployment.start();
        vertx.deployVerticle("starter.rx.Main");
    }

    @Override
    public Completable rxStart() {
        VertxRequestHandler handler = new VertxRequestHandler(vertx.getDelegate(), deployment);

        return vertx.createHttpServer()
                .requestHandler(x -> handler.handle(x.getDelegate()))
                .rxListen(80)
                .ignoreElement();
    }
}

V1.java

@ApplicationPath("v1")
public class V1 extends Application {
    private final Set<Object> singletons = new HashSet<>();

    public V1() {
        singletons.add(new Management());
    }

    @Override
    public Set<Object> getSingletons() {
        return singletons;
    }
}

Management.java

@Path("")
public class Management {
    @GET
    @Path("health")
    public CompletionStage<String> health() {
        return Flowable.just("healthy").singleStage("");
    }
}

Logs

22:48:47.658 [main] INFO  o.jboss.resteasy.resteasy_jaxrs.i18n -
                RESTEASY002225: Deploying jakarta.ws.rs.core.Application: class starter.rx.endpoint.V1
22:48:47.662 [main] INFO  o.jboss.resteasy.resteasy_jaxrs.i18n -
                RESTEASY002220: Adding singleton resource starter.rx.endpoint.Management from Application class starter.rx.endpoint.V1

Output

$ curl http://localhost:80/health
healthy

$ curl -i http://localhost:80/v1/health
HTTP/1.1 404 Not Found
transfer-encoding: chunked

These are the libs that I'm using

      "io.vertx" % "vertx-core" % "4.3.1",
      "org.jboss.resteasy" % "resteasy-vertx" % "6.0.1.Final",
      "io.vertx" % "vertx-rx-java3" % "4.3.1",

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文