Apache Camel 抛出 NoSuchEndPointException

问题描述 投票:0回答:1

我无法从特定文件夹读取文件 这是我的 routebuilder 代码

@Component("RequestFileRouteBuilder")
public class RequestFileRouteBuilder extends RouteBuilder{
       @Override
       public void configure() throws Exception{
              from("file:files/input")
             .routeId("Myroute")
             .process(Myprocessor);//processes the file input
       }
}

由于安全违规,我无法共享我们在项目中使用的整个 pom.xml 文件 但是我已经包括了骆驼文件,骆驼弹簧,骆驼豆,骆驼核心。

运行我的应用程序后出现的错误如下

由:org.apache.camel.NoSuchEndPointException 引起:找不到端点 cp:file://files/input,请检查您的类路径是否包含所需的 Camel 组件 jar。

我实际上在浏览了这个站点之后添加了骆驼文件依赖项 https://camel.apache.org/components/3.20.x/file-component.html

我哪里会出错?

java spring-boot apache-camel
1个回答
0
投票

这段代码似乎工作正常。下面是在我的机器上运行良好的代码片段。

@Component("requestFileRouteBuilder")
public class RequestFileRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception{
    from("file:C:/files/input/")
            .routeId("RequestFileRouteId")
            .process(exchange -> {log.info(exchange.getIn().getBody(String.class));});
}}

以下是应用程序的日志

2023-04-02 12:08:59.987  INFO 7192 --- [           main] o.a.c.impl.engine.AbstractCamelContext   :     Started RequestFileRouteId (file://C:/files/input/)

2023-04-02 12:08:59.987  INFO 7192 --- [           main] o.a.c.impl.engine.AbstractCamelContext   : Apache Camel 3.14.0 (camel-1) started in 420ms (build:83ms init:313ms start:24ms)
2023-04-02 12:08:59.994  INFO 7192 --- [           main] com.example.Application                  : Started Application in 6.136 seconds (JVM running for 7.67)
2023-04-02 12:09:16.841  INFO 7192 --- [C:/files/input/] c.example.route.RequestFileRouteBuilder  : Test Message

以下可能是我能想到的问题:

  1. 您是否将完整路径传递到输入目录?

  2. 您是否在 pom xml 中包含以下依赖项?

     <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
     </dependency>
     <dependency>
         <groupId>org.apache.camel.springboot</groupId>
         <artifactId>camel-spring-boot-starter</artifactId>
     </dependency>
    

另外,你需要检查你使用的spring boot版本和camel版本是否兼容。

© www.soinside.com 2019 - 2024. All rights reserved.