首页 > 解决方案 > 无法解析端点:没有找到带有方案的组件:exec

问题描述

我正在尝试使用 Apache Camel 调用一个简单的 shell 脚本,但出现错误:

Failed to resolve endpoint: exec:///usr/local/karaf/data/tmp/test.sh due to: No component found with scheme: exec

在我的 camel-context.xml 我有

  <route id="common_route">
    <from uri="direct:common_route" />
    <to uri="exec:/usr/local/karaf/data/tmp/test.sh"/>
  </route>

在我的 pom.xml

 <dependency>
   <groupId>org.apache.camel</groupId>
   <artifactId>camel-exec</artifactId>
   <version>${camel.version}</version>
 </dependency>

我们正在使用 Camel 版本 2.15.3。我们正在使用 Spring Camel。有任何想法吗?这是必须如此简单以至于非常令人沮丧的事情之一。

顺便说一句,如果我使用 exec:/usr/....exec:///usr/....

提前致谢。

标签: apache-camelspring-camel

解决方案


我想到了。文档没有提到这一点..至少,没有在骆驼执行页面上。

1:我必须将这一行添加 org.apache.camel.component.exec 到我的 pom.xml 中

 <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Spring-Context>*;create-asynchronously:=false</Spring-Context>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Import-Package>
                          ...
                          org.apache.camel.component.exec
                          ...

2:我必须在 Karaf 控制台中运行以下命令:

bundle:install mvn:org.apache.camel/camel-exec/2.15.3
bundle:install mvn:org.apache.commons/commons-exec/1.3
bundle:install mvn:commons-io/commons-io/1.4

推荐阅读