Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache Camel REST-未连接_Rest_Spring Boot_Apache Camel_Spring Camel - Fatal编程技术网

Apache Camel REST-未连接

Apache Camel REST-未连接,rest,spring-boot,apache-camel,spring-camel,Rest,Spring Boot,Apache Camel,Spring Camel,我正在尝试让ApacheCamel的RESTDSL工作,但它无法连接到我 我有一个名为RouteBuilder的程序: @Override public void configure() { restConfiguration().component("servlet") .contextPath("/") .enableCORS(true) .dataFormatProperty("prettyPrint", "true") .apiContex

我正在尝试让ApacheCamel的RESTDSL工作,但它无法连接到我

我有一个名为RouteBuilder的程序:

@Override
public void configure() {
restConfiguration().component("servlet")
      .contextPath("/")
      .enableCORS(true)
      .dataFormatProperty("prettyPrint", "true")
      .apiContextPath("/api-doc")
      .apiProperty("api.version", buildVersion)
      .apiProperty("cors", "true")
      .bindingMode(RestBindingMode.json);

rest("/say/hello")
      .get().route().transform().constant("Hello World");
}
但是这些路线实际上不起作用

这是在一个SpringBoot应用程序中,该应用程序具有通过JAX-RS定义的其他REST端点,但这是一个集成包,我希望能够单独保存。奇怪的是,几个月前我还没开始做其他事情,但现在,回头看,我甚至不能让这个简单的端点工作

我的Maven pom.xml中有Camel,似乎一切都正常启动,但当我点击http://localhost:9071/say/hello时,什么也没有发生,我只得到了标准的Tomcat 404页面

关于我遗漏了什么有什么想法吗?

根据以下内容:

从Camel的2.19版开始,此配置已作为 CamelServlet默认设置为“/camel”

所以/camel/say/hello是正确的URL,它对我很有用。仍然在研究如何定制这个

编辑:

以下是如何在Spring Boot下定制此功能。将属性添加到application.properties,如下所示:

camel.component.servlet.mapping.contextPath=/*
据此:

从Camel的2.19版开始,此配置已作为 CamelServlet默认设置为“/camel”

所以/camel/say/hello是正确的URL,它对我很有用。仍然在研究如何定制这个

编辑:

以下是如何在Spring Boot下定制此功能。将属性添加到application.properties,如下所示:

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

您是否已将RouteBuilder添加到CamelContext?还要注意您的url
http://localhost:9071/say/hello
。它有一个额外的冒号。删除它可能会使TrikCamel REST DSL向URI添加
/REST
。试试这个:
http://localhost:9071/rest/say/hello
。我怀疑您的路线没有添加到camelcontext中,因此也没有添加404。在spring boot中查看路由是否实际为“活动”。在spring boot中如何查看路由是否实际为“活动”?我知道正在调用我的RouteBuilder,因为它遇到了断点。我还在CamelServlet类中设置断点,并对其进行实例化和初始化。在初始化过程中,它在我的route builder中设置了配置。您是否已将RouteBuilder添加到CamelContext?还要注意您的url
http://localhost:9071/say/hello
。它有一个额外的冒号。删除它可能会使TrikCamel REST DSL向URI添加
/REST
。试试这个:
http://localhost:9071/rest/say/hello
。我怀疑您的路线没有添加到camelcontext中,因此也没有添加404。在spring boot中查看路由是否实际为“活动”。在spring boot中如何查看路由是否实际为“活动”?我知道正在调用我的RouteBuilder,因为它遇到了断点。我还在CamelServlet类中设置断点,并对其进行实例化和初始化。在初始化过程中,它在我的route builder中设置了配置。您是否能够了解如何自定义/camel上下文根?谢谢你的回答,我回答了。我想是这样的:restConfiguration().component(“servlet”).contextPath(properties.getRestContext())您能想出如何自定义/camel上下文根吗?谢谢你的回答,我回答了。我认为这可以做到:restConfiguration().component(“servlet”).contextPath(properties.getRestContext())