[英]Apache Camel Rest endpoint with DSL in Spring Boot adds /camel to the path
I'm trying to build a module to plug into a Spring Boot application.我正在尝试构建一个模块以插入 Spring 引导应用程序。 This module should expose some REST endpoints and I'm trying out building them with Camel because I don't want to have to add things to web.xml, etc.这个模块应该暴露一些 REST 端点,我正在尝试用 Camel 构建它们,因为我不想向 web.Z0F635D0E0F3874FFF8B581C132E6C7AZ 等添加东西。
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");
The problem I'm having is that instead of being at /my/foo/123?status=abc I have to hit it at /camel/my/foo/123?status=abc.我遇到的问题是,我必须在 /camel/my/foo/123?status=abc 上点击它,而不是在 /my/foo/123?status=abc。
It's doing this because it's defaulting to using the Camel Servlet as the REST endpoint from the DSL, and I'm fine with that, but I don't want it to put the "/camel" at the start of my path.这样做是因为它默认使用 Camel Servlet 作为 DSL 的 REST 端点,我对此很好,但我不希望它把“/camel”放在我路径的开头。 I should note that this behavior is the same with or without the .component("servlet")
我应该注意,无论是否使用.component("servlet")
,此行为都是相同的
Any way to change that?有什么办法可以改变吗?
You can control this in your application.properties or application.yml 您可以在application.properties或application.yml中控制它
eg 例如
camel.component.servlet.mapping.contextPath=/api/*
Reference https://github.com/apache/camel/blob/master/examples/camel-example-spring-boot-rest-jpa/src/main/resources/application.yml 参考https://github.com/apache/camel/blob/master/examples/camel-example-spring-boot-rest-jpa/src/main/resources/application.yml
With Spring Boot 2.7.2+ and Apache Camel 3.18.0+, the key is now:使用 Spring Boot 2.7.2+ 和 Apache Camel 3.18.0+,现在的关键是:
camel.servlet.mapping.context-path=/api/*
instead of代替
camel.component.servlet.mapping.contextPath=/api/*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.