从无到有构建大型电商微服务架构,eclipse构建springcloud消费者方引起的问题(Caused by: java.lang.NoClassDefFoundError: feign/Fe(代码

Posted qingruihappy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从无到有构建大型电商微服务架构,eclipse构建springcloud消费者方引起的问题(Caused by: java.lang.NoClassDefFoundError: feign/Fe(代码相关的知识,希望对你有一定的参考价值。

 1 2018-12-31 14:28:38.180  INFO 37860 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]a9cd3b1: startup date [Mon Dec 31 14:28:38 CST 2018]; root of context hierarchy
 2 2018-12-31 14:28:38.519  INFO 37860 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 javax.inject.Inject annotation found and supported for autowiring
 3 2018-12-31 14:28:38.551  INFO 37860 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean configurationPropertiesRebinderAutoConfiguration of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$167269fd] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
 4 
 5   .   ____          _            __ _ _
 6  /\ / ____ __ _ _(_)_ __  __ _    
 7 ( ( )\___ | _ | _| | _ / _` |    
 8  \/  ___)| |_)| | | | | || (_| |  ) ) ) )
 9     |____| .__|_| |_|_| |_\__, | / / / /
10  =========|_|==============|___/=/_/_/_/
11  :: Spring Boot ::       (v1.5.13.RELEASE)
12 
13 2018-12-31 14:28:39.030  INFO 37860 --- [           main] com.youfan.Application                   : No active profile set, falling back to default profiles: default
14 2018-12-31 14:28:39.046  INFO 37860 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]17a87e37: startup date [Mon Dec 31 14:28:39 CST 2018]; parent: org.spring[email protected]a9cd3b1
15 2018-12-31 14:28:39.759  INFO 37860 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=b16d5713-16a3-3a02-969f-90932a7d0adc
16 2018-12-31 14:28:39.779  INFO 37860 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 javax.inject.Inject annotation found and supported for autowiring
17 2018-12-31 14:28:39.800  WARN 37860 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name productMapper defined in file [D:dataeclipse-workspaceyoufanshopyoufanPinDaoIndex	argetclassescomyoufanmapperProductMapper.class]: Unsatisfied dependency expressed through bean property sqlSessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name com.youfan.service.SchedualServiceHi: Failed to introspect bean class [org.springframework.cloud.netflix.feign.FeignClientFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: feign/Feign$Builder
18 2018-12-31 14:28:39.800  WARN 37860 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name methodValidationPostProcessor defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsatisfied dependency expressed through method methodValidationPostProcessor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name com.youfan.service.SchedualServiceHi: Failed to introspect bean class [org.springframework.cloud.netflix.feign.FeignClientFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: feign/Feign$Builder
19 Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name productMapper defined in file [D:dataeclipse-workspaceyoufanshopyoufanPinDaoIndex	argetclassescomyoufanmapperProductMapper.class]: Unsatisfied dependency expressed through bean property sqlSessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name com.youfan.service.SchedualServiceHi: Failed to introspect bean class [org.springframework.cloud.netflix.feign.FeignClientFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: feign/Feign$Builder
20 2018-12-31 14:28:39.807  INFO 37860 --- [           main] utoConfigurationReportLoggingInitializer : 
21 
22 Error starting ApplicationContext. To display the auto-configuration report re-run your application with debug enabled.
23 2018-12-31 14:28:39.814 ERROR 37860 --- [           main] o.s.boot.SpringApplication               : Application startup failed
24 
25 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name methodValidationPostProcessor defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsatisfied dependency expressed through method methodValidationPostProcessor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name com.youfan.service.SchedualServiceHi: Failed to introspect bean class [org.springframework.cloud.netflix.feign.FeignClientFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: feign/Feign$Builder
26     at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
27     at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
28     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1181) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
29     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1075) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
30     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
31     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
32     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
33     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
34     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
35     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
36     at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:225) ~[spring-context-4.3.17.RELEASE.jar:4.3.17.RELEASE]
37     at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:703) ~[spring-context-4.3.17.RELEASE.jar:4.3.17.RELEASE]
38     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528) ~[spring-context-4.3.17.RELEASE.jar:4.3.17.RELEASE]
39     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.13.RELEASE.jar:1.5.13.RELEASE]
40     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.13.RELEASE.jar:1.5.13.RELEASE]
41     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.13.RELEASE.jar:1.5.13.RELEASE]
42     at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.13.RELEASE.jar:1.5.13.RELEASE]
43     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.13.RELEASE.jar:1.5.13.RELEASE]
44     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.13.RELEASE.jar:1.5.13.RELEASE]
45     at com.youfan.Application.main(Application.java:61) [classes/:na]
46 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name com.youfan.service.SchedualServiceHi: Failed to introspect bean class [org.springframework.cloud.netflix.feign.FeignClientFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: feign/Feign$Builder
47     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:269) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
48     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1126) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
49     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
50     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getSingletonFactoryBeanForTypeCheck(AbstractAutowireCapableBeanFactory.java:931) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
51     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:808) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
52     at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:564) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
53     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:432) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
54     at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:395) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
55     at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:206) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
56     at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1267) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
57     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1101) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
58     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
59     at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
60     at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
61     ... 19 common frames omitted
62 Caused by: java.lang.NoClassDefFoundError: feign/Feign$Builder
63     at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_181]
64     at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_181]
65     at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_181]
66     at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) ~[spring-core-4.3.17.RELEASE.jar:4.3.17.RELEASE]
67     at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524) ~[spring-core-4.3.17.RELEASE.jar:4.3.17.RELEASE]
68     at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510) ~[spring-core-4.3.17.RELEASE.jar:4.3.17.RELEASE]
69     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:247) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
70     ... 32 common frames omitted
71 Caused by: java.lang.ClassNotFoundException: feign.Feign$Builder
72     at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_181]
73     at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_181]
74     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_181]
75     at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_181]
76     ... 39 common frames omitted

解决方案:

是由于jar包冲突引起的。

1.5.9 pom依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-feign</artifactId>
</dependency>

2.0.x pom 依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
修改一下配置文件!

之后updatemaven一下

 

如果上面方法还是不行就把本地下载好的jar包全部删除掉之后在下载jar包就可以了。

假如你现在还在为自己的技术担忧,假如你现在想提升自己的工资,假如你想在职场上获得更多的话语权,假如你想顺利的度过35岁这个魔咒,假如你想体验BAT的工作环境,那么现在请我们一起开启提升技术之旅吧,详情请点击http://106.12.206.16:8080/qingruihappy/index.html

以上是关于从无到有构建大型电商微服务架构,eclipse构建springcloud消费者方引起的问题(Caused by: java.lang.NoClassDefFoundError: feign/Fe(代码的主要内容,如果未能解决你的问题,请参考以下文章

从无到有构建大型电商微服务亿级架构(全套3个阶段)

大型电商微服务项目视频教程

基于企业自建电商平台来思考中台和微服务架构演进

构建SpringBoot,SpringCloud微服务架构分布式电商项目实战

从无到有构建亿级微服务秒杀系统(真实工业界案例)

16.凤凰架构:构建可靠的大型分布式系统 --- 向微服务迈进