Reputation: 69
I encountered a problem with my Ribbon application. Here is my code:
@SpringBootApplication
@EnableDiscoveryClient
@RestController
@RibbonClient(name= "bye", configuration=RibbonConfig.class )
public class RibbonAppApplication {
@Autowired
private RestTemplate restTemplate;
public static void main(String[] args) {
SpringApplication.run(RibbonAppApplication.class, args);
}
@GetMapping
public String getService() {
return restTemplate.getForObject("http://bye",String.class);
}
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
And my RibbonConfig.class
:
@Configuration
public class RibbonConfig {
@Bean
public IPing ribbonPing(IClientConfig config) {
return new PingUrl(false,"/health");
}
@Bean
public IRule ribbonRule(IClientConfig config) {
return new AvailabilityFilteringRule();
}
}
However, I got the following error:
Parameter 0 of method ribbonPing in practice.zuul.zach.ribbonapp.RibbonConfig required a bean of type 'com.netflix.client.config.IClientConfig' that could not be found.
Action: Consider defining a bean of type 'com.netflix.client.config.IClientConfig' in your configuration.
Is there any ways to solve it?
Upvotes: 2
Views: 3635
Reputation: 69
problem solved when i add this line in RibbonAppApplication class
@SpringBootApplication(scanBasePackages={"com.netflix.client.config.IClientConfig"})
Upvotes: 2