Skip to content

原书第二版67页的DefaultRibbonConfig的IClientConfig启动时报bean不存在,源码中也搜索不到,请问这个类的Bean需要自己实现吗? #11

Description

@xn-9527

原书第二版67页的DefaultRibbonConfig的IClientConfig启动时报bean不存在,作者提供的配套源码中也搜索不到实现,请问这个类的Bean需要自己实现吗?如果是要自己实现的话,请问如何设置参数?

报错如下:

Parameter 0 of method ribbonServerList in config.DefaultRibbonConfig 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.

书上源码:

@Configuration
public class DefaultRibbonConfig {
    @Bean
    public IRule ribbonRule() {
        return new BestAvailableRule();
    }

    @Bean
    public IPing ribbonPing() {
        return new PingUrl();
    }

    @Bean
    public ServerList<Server> ribbonServerList(IClientConfig clientConfig) {
        return new RibbonClientDefaultConfigurationTestsConfig.BazServiceList(clientConfig);
    }

    @Bean
    public ServerListSubsetFilter severListFilter() {
        return new ServerListSubsetFilter();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions