调用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);
        }
    }


谁能帮我这个。
谢谢。

最佳答案

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

07-26 06:30