Spring Boot 中带有 DSL 的 Apache Camel Rest 端点将 /camel 添加到路径中

Jas*_*ira 5 apache-camel spring-boot

我正在尝试构建一个模块以插入 Spring Boot 应用程序。这个模块应该公开一些 REST 端点,我正在尝试用 Camel 构建它们,因为我不想向 web.xml 等添加内容。

restConfiguration().component("servlet")
      .contextPath("/my")
      .apiContextPath("/api-doc")
      .apiProperty("api.title", "My REST API")
      .apiProperty("cors", "true")
      .apiContextRouteId("my-api")
      .bindingMode(RestBindingMode.json);

rest("/my").description("My REST Services")
      .get("foo/{id}").route().routeId("foo")
      .to("direct:foo");

from("direct:foo")
      .process(new FooParamParser())
      .log("Done");
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是,不是在 /my/foo/123?status=abc 我必须在 /camel/my/foo/123?status=abc 打它。

它这样做是因为它默认使用 Camel Servlet 作为来自 DSL 的 REST 端点,我对此很好,但我不希望它把“/camel”放在我的路径的开头。我应该注意到,无论有没有.component("servlet")

有什么办法可以改变吗?

lts*_*las 7

您可以在 application.properties 或 application.yml 中控制它

例如

camel.component.servlet.mapping.contextPath=/api/*
Run Code Online (Sandbox Code Playgroud)

参考https://github.com/apache/camel/blob/master/examples/camel-example-spring-boot-rest-jpa/src/main/resources/application.yml