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

编程知识 更新时间:2023-05-02 05:24:00

如果在微服务中用远程调用的时候,出现空指针异常,建议参考方法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

本文发布于:2023-04-26 05:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/be8a9997c276afb8a1384ab9e0f866f0.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:type   netflix   defining   bean   IClientConfig

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 104363文章数
  • 26212阅读数
  • 0评论数