nacos-discovery包名层级问题解决

 更新时间:2023年07月20日 14:29:05   作者:李晗  
这篇文章主要为大家介绍了nacos-discovery包名层级问题解决,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪

问题

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

使用 com 包名层级运行

运行结果:

2021-01-07 11:17:09.441  INFO 3848 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v2.2.12.RELEASE)
2021-01-07 11:17:10.294  INFO 3848 --- [  restartedMain] com.OrderNacosMain83                     : No active profile set, falling back to default profiles: default
2021-01-07 11:17:13.128  WARN 3848 --- [  restartedMain] o.s.boot.actuate.endpoint.EndpointId     : Endpoint ID 'nacos-discovery' contains invalid characters, please migrate to a valid format.
2021-01-07 11:17:13.430  WARN 3848 --- [  restartedMain] o.s.boot.actuate.endpoint.EndpointId     : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2021-01-07 11:17:13.688  INFO 3848 --- [  restartedMain] o.s.cloud.context.scope.GenericScope     : BeanFactory id=17c50fdc-ef7b-36a2-a80c-63c33ed55773
2021-01-07 11:17:14.573  INFO 3848 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 83 (http)
2021-01-07 11:17:14.591  INFO 3848 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-01-07 11:17:14.591  INFO 3848 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-01-07 11:17:14.772  INFO 3848 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-01-07 11:17:14.773  INFO 3848 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4452 ms
2021-01-07 11:17:15.216  WARN 3848 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ribbonServerList' defined in class path resource [com/alibaba/cloud/nacos/ribbon/NacosRibbonClientConfiguration.class]: Unsatisfied dependency expressed through method 'ribbonServerList' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.netflix.client.config.IClientConfig' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2021-01-07 11:17:15.220  INFO 3848 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2021-01-07 11:17:15.245  INFO 3848 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-01-07 11:17:15.577 ERROR 3848 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method ribbonServerList in com.alibaba.cloud.nacos.ribbon.NacosRibbonClientConfiguration 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.

使用 com.xxx 包名层级运行

运行结果:

2021-01-07 11:17:09.441  INFO 3848 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor

: Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v2.2.12.RELEASE)

2021-01-07 11:17:10.294  INFO 3848 --- [  restartedMain] com.OrderNacosMain83                     : No active profile set, falling back to default profiles: default
2021-01-07 11:17:13.128  WARN 3848 --- [  restartedMain] o.s.boot.actuate.endpoint.EndpointId     : Endpoint ID 'nacos-discovery' contains invalid characters, please migrate to a valid format.
2021-01-07 11:17:13.430  WARN 3848 --- [  restartedMain] o.s.boot.actuate.endpoint.EndpointId     : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2021-01-07 11:17:13.688  INFO 3848 --- [  restartedMain] o.s.cloud.context.scope.GenericScope     : BeanFactory

解决办法

使用多层级包名来运行项目

此项目使用版本

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com</groupId>
    <artifactId>stu-alibaba</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>15</maven.compiler.source>
        <maven.compiler.target>15</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       <spring-cloud.version>Hoxton.SR8</spring-cloud.version>
       <spring-boot.version>2.2.12.RELEASE</spring-boot.version>
       <spring-cloud-alibaba.version>2.2.3.RELEASE</spring-cloud-alibaba.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${spring-cloud-alibaba.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.4.0</version>
            </plugin>
        </plugins>
    </build>
</project>

以上就是nacos-discovery包名层级问题解决的详细内容,更多关于nacos discovery包名层级的资料请关注脚本之家其它相关文章!

相关文章

  • Java项目之java+springboot+ssm实现理财管理系统设计

    Java项目之java+springboot+ssm实现理财管理系统设计

    这篇文章主要介绍了Java项目java+springboot+ssm实现理财管理系统设计,使用了当前较为流行的spring boot,spring,spring mvc,mybatis,shiro框架分页处理使用了pagehelper进行操作,需要的朋友可以参考一下
    2022-03-03
  • MyBatis通过JDBC数据驱动生成的执行语句问题

    MyBatis通过JDBC数据驱动生成的执行语句问题

    这篇文章主要介绍了MyBatis通过JDBC数据驱动生成的执行语句问题的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下
    2016-08-08
  • Java矢量队列Vector使用示例

    Java矢量队列Vector使用示例

    Vector类实现了一个动态数组。和ArrayList很相似,但是两者是不同的Vector是同步访问的;Vector包含了许多传统的方法,这些方法不属于集合框架
    2023-01-01
  • java集合类ArrayList和Vector的区别面试精讲

    java集合类ArrayList和Vector的区别面试精讲

    这篇文章主要为大家介绍了java集合类ArrayList和Vector的区别面试全面讲解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-10-10
  • 如何通过SpringBoot实现商城秒杀系统

    如何通过SpringBoot实现商城秒杀系统

    这篇文章主要介绍了如何通过SpringBoot实现商城秒杀系统,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2019-11-11
  • Springboot实现多线程注入bean的工具类操作

    Springboot实现多线程注入bean的工具类操作

    这篇文章主要介绍了Springboot实现多线程注入bean的工具类操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2020-08-08
  • java实现简易计算器功能

    java实现简易计算器功能

    这篇文章主要为大家详细介绍了java实现简易计算器功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-06-06
  • Java使用正则表达式实现找出数字功能示例

    Java使用正则表达式实现找出数字功能示例

    这篇文章主要介绍了Java使用正则表达式实现找出数字功能,结合实例形式分析了Java针对数字的匹配查找及非数字替换操作相关实现技巧,需要的朋友可以参考下
    2017-03-03
  • Java手写线程池之向JDK线程池进发

    Java手写线程池之向JDK线程池进发

    在前面的文章自己动手写乞丐版线程池中,我们写了一个非常简单的线程池实现,这个只是一个非常简单的实现,在本篇文章当中我们将要实现一个和JDK内部实现的线程池非常相似的线程池,需要的可以了解一下
    2022-10-10
  • 我从jdk1.8升级到jdk11所遇到的坑都有这些

    我从jdk1.8升级到jdk11所遇到的坑都有这些

    这篇文章主要介绍了从jdk1.8升级到jdk11将会遇到的一些坑,本文给大家分享解决方案对大家的学习或工作具有参考借鉴价值,对jdk1.8升级到jdk11相关知识感兴趣的朋友,快来看看吧
    2021-08-08

最新评论