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 包名层级运行

image

运行结果:

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 包名层级运行

image

运行结果:

2021-01-07 11:22:29.792  INFO 8776 --- [  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:22:30.527  INFO 8776 --- [  restartedMain] com.xxx.OrderNacosMain83                 : No active profile set, falling back to default profiles: default
2021-01-07 11:22:31.416  WARN 8776 --- [  restartedMain] o.s.boot.actuate.endpoint.EndpointId     : Endpoint ID 'nacos-discovery' contains invalid characters, please migrate to a valid format.
2021-01-07 11:22:31.762  WARN 8776 --- [  restartedMain] o.s.boot.actuate.endpoint.EndpointId     : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2021-01-07 11:22:31.982  INFO 8776 --- [  restartedMain] o.s.cloud.context.scope.GenericScope     : BeanFactory id=46a0ea06-4267-35b8-b400-145b3c52f871
2021-01-07 11:22:32.995  INFO 8776 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 83 (http)
2021-01-07 11:22:33.009  INFO 8776 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-01-07 11:22:33.009  INFO 8776 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-01-07 11:22:33.206  INFO 8776 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-01-07 11:22:33.206  INFO 8776 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2652 ms
2021-01-07 11:22:33.574  WARN 8776 --- [  restartedMain] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2021-01-07 11:22:33.574  INFO 8776 --- [  restartedMain] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2021-01-07 11:22:33.580  WARN 8776 --- [  restartedMain] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2021-01-07 11:22:33.581  INFO 8776 --- [  restartedMain] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2021-01-07 11:22:33.827  INFO 8776 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-01-07 11:22:34.153  INFO 8776 --- [  restartedMain] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'Nacos-Watch-Task-Scheduler'
2021-01-07 11:22:34.654  INFO 8776 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2021-01-07 11:22:34.851  INFO 8776 --- [  restartedMain] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2021-01-07 11:22:35.252  INFO 8776 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 83 (http) with context path ''
2021-01-07 11:22:35.350  INFO 8776 --- [  restartedMain] c.a.c.n.registry.NacosServiceRegistry    : nacos registry, DEFAULT_GROUP nacos-order-consumer 192.168.43.2:83 register finished
2021-01-07 11:22:35.464  INFO 8776 --- [  restartedMain] com.xxx.OrderNacosMain83                 : Started OrderNacosMain83 in 6.477 seconds (JVM running for 7.435)

解决办法

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

此项目使用版本



    4.0.0

    com
    stu-alibaba
    pom
    1.0-SNAPSHOT
    
    
        15
        15
        UTF-8
       Hoxton.SR8
       2.2.12.RELEASE
       2.2.3.RELEASE
    

    
        
            
                org.springframework.cloud
                spring-cloud-dependencies
                ${spring-cloud.version}
                pom
                import
            

            
                org.springframework.boot
                spring-boot-dependencies
                ${spring-boot.version}
                pom
                import
            

            
                com.alibaba.cloud
                spring-cloud-alibaba-dependencies
                ${spring-cloud-alibaba.version}
                pom
                import
            

        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
                2.4.0
            
        
    
    

你可能感兴趣的:(javaspringboot)