1. 程式人生 > >從無到有構建大型電商微服務架構(一),eclipse構建springcloud消費者方引起的問題(Caused by: java.lang.NoClassDefFoundError: feign/Feign$Builder)

從無到有構建大型電商微服務架構(一),eclipse構建springcloud消費者方引起的問題(Caused by: java.lang.NoClassDefFoundError: feign/Feign$Builder)

 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:\data\eclipse-workspace\youfanshop\youfanPinDaoIndex\target\classes\com\youfan\mapper\ProductMapper.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:\data\eclipse-workspace\youfanshop\youfanPinDaoIndex\target\classes\com\youfan\mapper\ProductMapper.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