0

I'm creating a loadbalancer using Netflix round ribbon but i am not able to auto wire IClientConfig this object.

I tried this also @SpringBootApplication(scanBasePackages{"com.netflix.client.confg.IClientConfig"})

but this is also not working for me.

I'm getting this exception

org.spring framework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.netflix.client.config.IClientConfig' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

prachi
  • 113
  • 1
  • 8
  • Have you written @ Service annotation or @ Component annotation on the class IClientConfig.? are you calling this bean while application is starting or at a certain point after application has started? – Vinit Pillai Feb 15 '20 at 13:33
  • yes, i have mentioned @Configuration annotation this is my code ``@Configuration public class ClientAppConfiguration { @Bean public IRule ribbonRule(IClientConfig config) { System.out.println("HERE"); return new BestAvailableRule(); } @Bean public IPing ribbonPing() { return new PingUrl(); } }`` – prachi Feb 15 '20 at 13:54
  • Typically this means you have a ribbon bean that has been picked up by the normal application context. These need to be defined in separate configuration classes and referenced by @RibbonClient annotations – spencergibb Feb 15 '20 at 19:56
  • i have that separate class in that i have mentioned @RibbonClient annotation by mentioned my configuration class name ``@RibbonClient(name = "loadbalancer-web", configuration = ClientAppConfiguration.class) `` @spencergibb – prachi Feb 17 '20 at 09:33
  • 1
    Remove `@Configuration` from that class as documented – spencergibb Feb 18 '20 at 11:54

1 Answers1

0

I suspect your dependencies are not configured correctly. Is ribbon-core added as compile dependency in build.gradle or pom.xml?

please check if you have

runtime group: 'com.netflix.ribbon', name: 'ribbon-core', version: '2.7.17'

or

<dependency>
    <groupId>com.netflix.ribbon</groupId>
    <artifactId>ribbon-core</artifactId>
    <version>2.7.17</version>
    <scope>runtime</scope>
</dependency>