springboot集成eureka实现服务调用,启动服务端和客户端报错:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.eurekaClient' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.discovery.EurekaClient]: Factory method 'eurekaClient' threw exception; nested exception is java.lang.RuntimeException: Failed to initialize DiscoveryClient!
父级pom文件截图:
注册中心pom文件截图:
客服端pom文件截图:
服务端pom文件截图:
网上查了半天资料也找不到原因,后面问了大佬,说我注册中心、客服端和服务端三大模块都继承了父级依赖,导致客服端和服务端模块都有了eureka server包,但是配置却只配了注册中心模块为server,导致依赖和配置不同步导致的,把父级pom文件eureka server包移到注册中心模块pom文件,客服端和服务端模块不继承eureka server就能启动了,果然是这样的,如下图: