Camel路由创建错误,找不到方案的组件:mongodb

时间:2018-03-19 06:38:47

标签: java mongodb spring-boot apache-camel

我是Apache camel的新手,尝试编写一条路径,该路由应该从指定路径上的文件读取数据并将内容存储在mongodb中。 似乎我在指定mongodb路径时出错了,结果我在控制台上遇到错误(Failed to create route route1 at: >>> To[mongodb:myDb?database=email_response&collection=emailResponse&operation=save] <<< in route: Route(route1)[[From[file:C://workspace//Emai... because of Failed to resolve endpoint: mongodb://myDb?collection=emailResponse&database=email_response&operation=save due to: No component found with scheme: mongodb),请看看。

控制台输出

  

启动ApplicationContext时出错。显示条件报告   使用&#39; debug&#39;重新运行您的应用程序启用。 2018-03-19 12:02:43.234   ERROR 4616 --- [main] o.s.boot.SpringApplication
  :应用程序运行失败

     

org.apache.camel.spring.boot.CamelSpringBootInitializationException:   了java.lang.RuntimeException:   org.apache.camel.FailedToCreateRouteException:无法创建路由   route1 at:&gt;&gt;&gt;   为[mongodb的:MYDB数据库= email_response&安培;采集= emailResponse&安培;操作=保存]   &LT;&LT;&LT;在途中:   路线(ROUTE1)[[[文件:C:// //工作区鄂麦...   因为无法解析端点:   MongoDB的:// MYDB收集= emailResponse和放大器;数据库= email_response和放大器;操作=保存   由于:找不到与方案有关的组件:mongodb at   org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:126)   〜[camel-spring-boot-2.17.0.jar:2.17.0] at   org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:41)   〜[camel-spring-boot-2.17.0.jar:2.17.0] at   org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)   〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at   org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)   〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at   org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)   〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at   org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:399)   〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at   org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:353)   〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at   org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:887)   〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at   org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161)   〜[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at   org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552)   〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] at   org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)   〜[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at   org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)   [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at   org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)   [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at   org.springframework.boot.SpringApplication.run(SpringApplication.java:327)   [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at   org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)   [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at   org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)   [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE] at   com.era.conf.ApplicationConfiguration.main(ApplicationConfiguration.java:12)   [classes /:na]引起:java.lang.RuntimeException:   org.apache.camel.FailedToCreateRouteException:无法创建路由   route1 at:&gt;&gt;&gt;   为[mongodb的:MYDB数据库= email_response&安培;采集= emailResponse&安培;操作=保存]   &LT;&LT;&LT;在途中:   路线(ROUTE1)[[[文件:C:// //工作区鄂麦...   因为无法解析端点:   MongoDB的:// MYDB收集= emailResponse和放大器;数据库= email_response和放大器;操作=保存   由于:找不到与方案有关的组件:mongodb at   org.apache.camel.spring.boot.CamelSpringBootApplicationController.run(CamelSpringBootApplicationController.java:73)   〜[camel-spring-boot-2.17.0.jar:2.17.0] at   org.apache.camel.spring.boot.CamelMainRunController $ DaemonTask.run(CamelMainRunController.java:43)   〜[camel-spring-boot-2.17.0.jar:2.17.0] at   java.lang.Thread.run(Thread.java:745)〜[na:1.8.0_102] at at   org.apache.camel.spring.boot.CamelMainRunController.start(CamelMainRunController.java:36)   〜[camel-spring-boot-2.17.0.jar:2.17.0] at   org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:113)   〜[camel-spring-boot-2.17.0.jar:2.17.0] ...省略了16个常用帧   引起:org.apache.camel.FailedToCreateRouteException:失败   在以下位置创建路线route1:&gt;&gt;&gt;   为[mongodb的:MYDB数据库= email_response&安培;采集= emailResponse&安培;操作=保存]   &LT;&LT;&LT;在途中:   路线(路径1)[[[文件:// //工作区鄂麦...   因为无法解析端点:   MongoDB的:// MYDB收集= emailResponse和放大器;数据库= email_response和放大器;操作=保存   由于:找不到与方案有关的组件:mongodb at   org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1072)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:974)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3295)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3018)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.impl.DefaultCamelContext.access $ 000(DefaultCamelContext.java:175)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.impl.DefaultCamelContext $ 2.call(DefaultCamelContext.java:2848)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.impl.DefaultCamelContext $ 2.call(DefaultCamelContext.java:2844)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2867)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2844)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2813)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.main.Main.doStart(Main.java:127)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.main.MainSupport.run(MainSupport.java:138)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.spring.boot.CamelSpringBootApplicationController.run(CamelSpringBootApplicationController.java:68)   〜[camel-spring-boot-2.17.0.jar:2.17.0] ...省略了20个常用帧   引起:org.apache.camel.ResolveEndpointFailedException:失败   解决端点:   MongoDB的:// MYDB收集= emailResponse和放大器;数据库= email_response和放大器;操作=保存   由于:找不到与方案有关的组件:mongodb at   org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:594)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:79)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:211)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:107)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:113)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:62)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:56)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:534)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:495)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:219)   〜[camel-core-2.17.0.jar:2.17.0] at   org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1069)   〜[camel-core-2.17.0.jar:2.17.0] ...省略了35个常用帧

骆驼路线

@Override
    public void configure() throws Exception {
        from("file:C://workspace//EmailResponseAutomation//response//")
        .to("mongodb:myDb?database=email_response&collection=emailResponse&operation=save");
    }

依赖关系

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>

        <!-- Apache Camel -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
            <version>2.17.0</version>
        </dependency>
    </dependencies>

1 个答案:

答案 0 :(得分:4)

为了将Camel与MongoDB一起使用,您需要Camel MongoDB Component,添加

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-mongodb</artifactId>
    <version>2.17.0</version>
</dependency>

到你的pom。