With Ribbon, if you want to use a custom ServerList
implementation instead of the default ConfigurationBasedServerList
for a specific service, you can do it like this in the application configuration file:
my-service:
ribbon:
NIWSServerListClassName: com.myapp.MyCustomServerList
My issue is that I want to replace the default ConfigurationBasedServerList
for all services I declare to use the MyCustomServerList
.
I could just add the previous properties block for each service, but that could grow endlessly.
Is there a way to declare MyCustomServerList
as default?
I've also tried adding this bean to my @Configuration
class, but it only seems to work the first time I do a request:
@Bean
public ServerList<Server> ribbonServerList() {
return new MyCustomServerList();
}
See http://cloud.spring.io/spring-cloud-static/Dalston.SR1/#_customizing_the_ribbon_client
@RibbonClients(defaultConfiguration=MyConfig.class)
//...
class MyConfig {
@Bean
public ServerList<Server> ribbonServerList() {
return new MyCustomServerList();
}
}