栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

Consider defining a bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs‘ ...

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Consider defining a bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs‘ ...

2021-06-02 07:07:08.545  INFO 4044 --- [           main] com.example.client.ClientApplication     : Starting ClientApplication using Java 15 on DESKTOP-JQL00D4 with PID 4044 (C:Usersxxxworkspace-spring-tool-suite-4-4.8.1.RELEASEclienttargetclasses started by xxx in C:Usersxxxworkspace-spring-tool-suite-4-4.8.1.RELEASEclient)
2021-06-02 07:07:08.555  INFO 4044 --- [           main] com.example.client.ClientApplication     : No active profile set, falling back to default profiles: default
2021-06-02 07:07:10.045  INFO 4044 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=20f69ff4-2081-3357-9eb0-d6af76333385
2021-06-02 07:07:10.945  WARN 4044 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration': Unsatisfied dependency expressed through field 'optionalArgs'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.netflix.discovery.AbstractDiscoveryClientOptionalArgs' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2021-06-02 07:07:10.969  INFO 4044 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-06-02 07:07:11.013 ERROR 4044 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field optionalArgs in org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration required a bean of type 'com.netflix.discovery.AbstractDiscoveryClientOptionalArgs' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.netflix.discovery.AbstractDiscoveryClientOptionalArgs' in your configuration.

在配置eureka client时,启动应用后,一直报错,错误信息如上。错误信息提示缺少这样一个class: AbstractDiscoveryClientOptionalArgs,并且还有 No active profile set, falling back to default profiles的提示。

查看解决办法:
在创建project时,只是选择了如下eureka依赖:

    	
			org.springframework.cloud
			spring-cloud-starter-netflix-eureka-client
		

而eureka client 依赖的com.netflix.discovery.AbstractDiscoveryClientOptionalArgs 最终依赖于 spring-web-5.3.4.jar(https://www.hxstrive.com/article/932.htm 给出了详细解释)

于是我在pom.xml的依赖管理中添加了如下依赖,然后在STS中右击 --> maven --> update project,但是应用仍然启动不起来,报相同的错。


        org.springframework.boot
        spring-boot-starter-web

把整个项目删除,重新新建工程,在新建时选择eureka client 和 spring-web,再启动,一切正常了。

对比了新建的项目,我发现上面的 spring-boot-starter-web依赖需要添加到pom.xml的标签下的中,而不能添加到下的中。那么问题来了,这两处依赖有什么不同呢?

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/905338.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号