【问题标题】:Camel route should be annotated with component or configuration骆驼路线应使用组件或配置进行注释
【发布时间】:2018-12-21 12:11:57
【问题描述】:

我有骆驼路线,主要用于将文件从源移动到目标,如下所示

public class SimpleRouteBuilder extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        from("file:C:/inputFolder?noop=true").to("file:C:/outputFolder");
    }

}

问题是应该使用哪个注解(@component 或 @Configuration)来加载此路由

【问题讨论】:

    标签: apache-camel spring-camel camel-ftp


    【解决方案1】:

    如果您使用的是 Spring 或 Spring Boot 等,那么它应该是 @Component,它确保该类被登记到 Spring bean 注册表中,然后 Camel 扫描 RouteBuilder 类并自动添加到 CamelContext

    注意 Spring Boot 有一些它只扫描的类路径(我认为它是主类和子包的包),所以如果你把它放在外面的其他包中,你可能需要配置 spring boot 来扫描其他包。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-05
      • 1970-01-01
      • 2019-07-11
      • 1970-01-01
      • 1970-01-01
      • 2011-05-24
      • 1970-01-01
      相关资源
      最近更新 更多