今天遇到项目启动失败的异常,异常信息如下:

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!

往下排查,主要问题

Caused by: java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.setupDefaultSecurity(Lcom/thoughtworks/xstream/XStream;)V

没这个方法!!!代码构建运行正常,问题大概就是在环境了。

XStream这个包主要提供XML解析功能,eureka-client包里面会自动导入这个依赖。搜索一下发现除了eureka客户端还有其他包引入了这个依赖,其他包只是提供实体类的作用,试着把它排除掉,运行正常。

总结:依赖冲突了

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐