错误:在类路径

时间:2019-02-19 16:33:48

标签: java spring-boot apache-camel spring-camel

调用addRouteDefinition时出错。我正在动态添加休息到camelcontext。

错误

  

org.apache.camel.FailedToCreateRouteException:由于在类路径上找到多个RestConsumerFactory,因此无法创建路由。明确配置要使用的组件

RestsDefinition rests = camelContext.loadRestsDefinition(is);

camelContext.addRestDefinitions(rests.getRests());

for (RestDefinition restDefinition : rests.getRests()) {

        List<RouteDefinition> routeDefinitions = restDefinition.asRouteDefinition(camelContext);
        System.out.println(routeDefinitions);

        //camelContext.addRouteDefinitions(routeDefinitions);

        for (RouteDefinition route1 : routeDefinitions) {
            System.out.println("Route being Added : " + route1.getId());

            //Getting Error in this line
            camelContext.addRouteDefinition(route1);
        }
    }

有人可以帮助我吗? 谢谢。

1 个答案:

答案 0 :(得分:1)

问题在于RestConfiguration,因为在添加的camelcontext中未正确设置RestConfiguration。 camelContext.addRestConfiguration(restConfiguration);