在Spring Boot中使用DSL的Apache Camel Rest端点添加/ camel到路径

时间:2017-10-17 19:48:48

标签: spring-boot apache-camel

我正在尝试构建一个插入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");

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

它这样做是因为它默认使用Camel Servlet作为DSL的REST端点,我很好,但我不想要它把" /骆驼"在我的道路开始。我应该注意,无论有没有.component("servlet")

,这种行为都是一样的

有什么方法可以改变吗?

1 个答案:

答案 0 :(得分:4)

您可以在application.properties或application.yml

中控制它

例如

camel.component.servlet.mapping.contextPath=/api/*

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