Java 如何解决 Apache Camel 中的“无法创建路由 route1 异常”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21802003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to solve "Failed to create route route1 exception" in Apache Camel?
提问by Azhaguvel A
I am new for Apache Camel concept. I have tried to write sample code using with apache camel API's and I am getting the following exception when try to run the code.
我是 Apache Camel 概念的新手。我尝试使用 apache camel API 编写示例代码,但在尝试运行代码时出现以下异常。
Can anyone help me to solve this issue?
谁能帮我解决这个问题?
Here's the sample code and an exception as well,
这是示例代码和一个例外,
Sample Code :
示例代码:
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start")
.setHeader(Exchange.HTTP_URI,simple("`http://sample-host:8080/demo/get`"))
.to("http://emptyhost");
}
});
context.start();
ProducerTemplate template = context.createProducerTemplate();
System.out.println(template.requestBodyAndHeaders("direct:start", null, null,String.class));
Exception :
例外 :
Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
Failed to create route route1 at:
>>> To[`http://sample-host:8080/demo/get`] <<<
in route: Route(route1)
[[From[direct:start]] -> [`To[http://sample-host:8`…
because of
Failed to resolve endpoint: `http://sample-host:8080/demo/get`
due to:
No component found with scheme: http
采纳答案by Azhaguvel A
Dependency libraries were missing. So i have added those libraries and solved my issue.
缺少依赖库。所以我添加了这些库并解决了我的问题。
回答by user12766534
I got the same error, dis is due to use of latest dependencies. so use the older dependencies and try.
我遇到了同样的错误,dis 是由于使用了最新的依赖项。所以使用旧的依赖项并尝试。