admin管理员组文章数量:1295636
I am trying to expose a REST API from Apache Camel project running on Spring Boot.
I am following the instructions here - .html#_components_supporting_rest_dsl
I selected the platform HTTP component, since the document mentions this:
The Platform HTTP is used to allow Camel to use the existing HTTP server from the runtime. For example, when running Camel on Spring Boot, Quarkus, or other runtimes.
I added the following maven dependencies to the project.
<dependency>
<groupId>.apache.camel.springboot</groupId>
<artifactId>camel-rest-starter</artifactId>
<version>4.6.0</version>
</dependency>
<dependency>
<groupId>.apache.camel.springboot</groupId>
<artifactId>camel-platform-http-starter</artifactId>
<version>4.6.0</version>
</dependency>
I added a simple REST Route.
@Component
public class RestAPIRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("rest:get:hello")
.transform().constant("Hello World");
}
}
When I start the app, I get the following error:
.apache.camel.FailedToStartRouteException: Failed to start route route1 because of Cannot find RestConsumerFactory in Registry or as a Component to use
.....
Caused by: java.lang.IllegalStateException: Cannot find RestConsumerFactory in Registry or as a Component to use
at .apache.camelponent.rest.RestEndpoint.createConsumer(RestEndpoint.java:601) ~[camel-rest-4.6.0.jar:4.6.0]
at .apache.camel.impl.engine.DefaultRoute.gatherRootServices(DefaultRoute.java:670) ~[camel-base-engine-4.6.0.jar:4.6.0]
at .apache.camel.impl.engine.DefaultRoute.gatherServices(DefaultRoute.java:654) ~[camel-base-engine-4.6.0.jar:4.6.0]
at .apache.camel.impl.engine.DefaultRoute.initializeServices(DefaultRoute.java:225) ~[camel-base-engine-4.6.0.jar:4.6.0]
at .apache.camel.impl.engine.RouteService.doSetup(RouteService.java:150) ~[camel-base-engine-4.6.0.jar:4.6.0]
at .apache.camel.impl.engine.RouteService.setUp(RouteService.java:129) ~[camel-base-engine-4.6.0.jar:4.6.0]
... 22 common frames omitted
What additional configuration is needed for getting started with this REST API?
I am trying to expose a REST API from Apache Camel project running on Spring Boot.
I am following the instructions here - https://camel.apache./manual/rest-dsl.html#_components_supporting_rest_dsl
I selected the platform HTTP component, since the document mentions this:
The Platform HTTP is used to allow Camel to use the existing HTTP server from the runtime. For example, when running Camel on Spring Boot, Quarkus, or other runtimes.
I added the following maven dependencies to the project.
<dependency>
<groupId>.apache.camel.springboot</groupId>
<artifactId>camel-rest-starter</artifactId>
<version>4.6.0</version>
</dependency>
<dependency>
<groupId>.apache.camel.springboot</groupId>
<artifactId>camel-platform-http-starter</artifactId>
<version>4.6.0</version>
</dependency>
I added a simple REST Route.
@Component
public class RestAPIRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("rest:get:hello")
.transform().constant("Hello World");
}
}
When I start the app, I get the following error:
.apache.camel.FailedToStartRouteException: Failed to start route route1 because of Cannot find RestConsumerFactory in Registry or as a Component to use
.....
Caused by: java.lang.IllegalStateException: Cannot find RestConsumerFactory in Registry or as a Component to use
at .apache.camelponent.rest.RestEndpoint.createConsumer(RestEndpoint.java:601) ~[camel-rest-4.6.0.jar:4.6.0]
at .apache.camel.impl.engine.DefaultRoute.gatherRootServices(DefaultRoute.java:670) ~[camel-base-engine-4.6.0.jar:4.6.0]
at .apache.camel.impl.engine.DefaultRoute.gatherServices(DefaultRoute.java:654) ~[camel-base-engine-4.6.0.jar:4.6.0]
at .apache.camel.impl.engine.DefaultRoute.initializeServices(DefaultRoute.java:225) ~[camel-base-engine-4.6.0.jar:4.6.0]
at .apache.camel.impl.engine.RouteService.doSetup(RouteService.java:150) ~[camel-base-engine-4.6.0.jar:4.6.0]
at .apache.camel.impl.engine.RouteService.setUp(RouteService.java:129) ~[camel-base-engine-4.6.0.jar:4.6.0]
... 22 common frames omitted
What additional configuration is needed for getting started with this REST API?
Share asked Feb 12 at 3:28 ShankarShankar 2,8353 gold badges30 silver badges58 bronze badges1 Answer
Reset to default 0I found that this above configuration assumes that the Spring MVC web server is running.
Source: https://github/apache/camel-spring-boot-examples/blob/main/platform-http/pom.xml
Add the following to the configuration to start the embedded web server, which is the platform http that Camel needs.
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
本文标签:
版权声明:本文标题:java - What is the minimum configuration to define a REST service on Apache Camel running on Spring Boot? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741622917a2388914.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论