自定义负载均衡算法报错:expected single matching bean but found 2: myRule,getRule

org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.netflix.loadbalancer.IRule' available: expected single matching bean but found 2: myRule,getRule

原因:

配置了两个地方,然后冲突了,springcloud不知道具体加载哪个算法

 @Bean
    public IRule getRule(){
        return new MyRule();
    }
@RibbonClient(name = "SPRINGCLOUD-PROVIDER-DEPT",configuration = MyRule.class)

解决方法:删掉其中一个

你可能感兴趣的:(java,前端,spring)