Error creating bean with name 'eurekaClient' defined in BeanDefinition defined in class path resourc

分手后的思念是犯贱 2022-03-25 13:14 393阅读 0赞

直接看报错信息

  1. 2019-01-21 10:11:12.976 [ERROR] [main] [SpringApplication:771] : Application startup failed
  2. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eurekaClient' defined in BeanDefinition defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.<init>()
  3. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1110)
  4. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1054)
  5. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
  6. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
  7. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
  8. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  9. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
  10. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
  11. at org.springframework.beans.factory.support.AbstractBeanFactory.isSingleton(AbstractBeanFactory.java:428)
  12. at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:424)
  13. at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:390)
  14. at org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$PreserveErrorControllerTargetClassPostProcessor.postProcessBeanFactory(ErrorMvcAutoConfiguration.java:334)
  15. at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:281)
  16. at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:176)
  17. at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)
  18. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)
  19. at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
  20. at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
  21. at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
  22. at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
  23. at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
  24. at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
  25. at com.xxx.api.Application.main(Application.java:31)
  26. Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.<init>()
  27. at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:85)
  28. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1102)
  29. ... 22 common frames omitted
  30. Caused by: java.lang.NoSuchMethodException: org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.<init>()
  31. at java.lang.Class.getConstructor0(Class.java:3082)
  32. at java.lang.Class.getDeclaredConstructor(Class.java:2178)
  33. at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:80)
  34. ... 23 common frames omitted

GenericScope$LockedScopedProxyFactoryBean:No default constructor found没有默认构造器。。

java.lang.NoSuchMethodException: org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.

没有这个方法。。。

进行搜索,发现这个类可以找到,同时方法也是可以找到,并且找到2个!!!重点就是2个,很简单,直接show dependencies排除掉多余jar即可。

总结:类似的问题只看报错(方法、构造器),可能无法直接明白的知道是jar冲突了,但是经过简单的分析也可以很快发现问题

补充:如何show dependencies

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQxMDcwMzkz_size_16_color_FFFFFF_t_70

选择show dependencies

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQxMDcwMzkz_size_16_color_FFFFFF_t_70 1

着重看红色线标识部分,红色虚线先排除掉,方法是:选择jar包,右键排除

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQxMDcwMzkz_size_16_color_FFFFFF_t_70 2

发表评论

表情:
评论列表 (有 0 条评论,393人围观)

还没有评论,来说两句吧...

相关阅读