如果在微服务中用远程调用的时候,出现空指针异常,建议参考方法2.
在微服务项目中,启动一个springboot项目时,报错信息如下:

Description:

Parameter 0 of method ribbonServerList in com.alibaba.cloud.nacos.ribbon.NacosRibbonClientConfiguration required a bean of type 'comflix.client.config.IClientConfig' that could not be found.


Action:

Consider defining a bean of type 'comflix.client.config.IClientConfig' in your configuration.

下面说一下解决方法:

  1. 如果你单纯的正常启动,不需要用到服务间远程调用,直接在启动类中配置一个bean,或者写一个配置文件,把这个bean添加上。但是,这种会出现openFeign远程调用会出现空指针异常。
    @Bean
    public IClientConfig iClientConfig() {
        return new DefaultClientConfigImpl();
    }
  1. 如果项目中用openFeign远程调用,建议选择以下解决方法:
    首先,看一下我的启动所在项目目录结构

    注意点:启动类要放在三级目录或者更深层级,这时候不需要配置IClientConfig 这个bean

ps: 希望能对大家有帮助~

更多推荐

Consider defining a bean of type ‘com.netflix.client.config.IClientConfig‘ in yo