Caused by: java.lang.ClassNotFoundException: feign.Feign$Builder 正确解决方法

学习Spring Cloud Feign 的途中发生了一个意外的错误:

Caused by: java.lang.ClassNotFoundException: feign.Feign$Builder

在网络上查询了之后都说是因为pom缺少依赖,只要加入

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

如此的依赖就能恢复正常。
但是!我本来就是添加了依赖那么该怎么办呢。
然后我有查到可能是因为maven下载jar包错误,但是我使用maven–test并没有任何jar包报错信息。
在eclipse的后台输出的最后一行中,我发现了有一条JVM类加载器的信息,他会打印出JVM在运行时加载了哪些类。

2018-07-23 15:55:57.090  INFO 9152 --- [           main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/resources.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/rt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/jsse.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/jce.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/charsets.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/jfr.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/access-bridge-64.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/cldrdata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/dnsns.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/jaccess.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/jfxrt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/localedata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/nashorn.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/sunec.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/sunjce_provider.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/sunmscapi.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/sunpkcs11.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/zipfs.jar, file:/D:/workspace/feign-consumer/target/classes/, file:/D:/MavenRes/NewMavenLib/org/springframework/boot/spring-boot-starter/1.3.7.RELEASE/spring-boot-starter-1.3.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/boot/spring-boot/1.3.7.RELEASE/spring-boot-1.3.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/spring-context/4.2.7.RELEASE/spring-context-4.2.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/boot/spring-boot-autoconfigure/1.3.7.RELEASE/spring-boot-autoconfigure-1.3.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/boot/spring-boot-starter-logging/1.3.7.RELEASE/spring-boot-starter-logging-1.3.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar, file:/D:/MavenRes/NewMavenLib/ch/qos/logback/logback-core/1.1.7/logback-core-1.1.7.jar, file:/D:/MavenRes/NewMavenLib/org/slf4j/jcl-over-slf4j/1.7.21/jcl-over-slf4j-1.7.21.jar, file:/D:/MavenRes/NewMavenLib/org/slf4j/jul-to-slf4j/1.7.21/jul-to-slf4j-1.7.21.jar, file:/D:/MavenRes/NewMavenLib/org/slf4j/log4j-over-slf4j/1.7.21/log4j-over-slf4j-1.7.21.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/spring-core/4.2.7.RELEASE/spring-core-4.2.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/boot/spring-boot-starter-web/1.3.7.RELEASE/spring-boot-starter-web-1.3.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/boot/spring-boot-starter-tomcat/1.3.7.RELEASE/spring-boot-starter-tomcat-1.3.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/apache/tomcat/embed/tomcat-embed-core/8.0.36/tomcat-embed-core-8.0.36.jar, file:/D:/MavenRes/NewMavenLib/org/apache/tomcat/embed/tomcat-embed-el/8.0.36/tomcat-embed-el-8.0.36.jar, file:/D:/MavenRes/NewMavenLib/org/apache/tomcat/embed/tomcat-embed-logging-juli/8.0.36/tomcat-embed-logging-juli-8.0.36.jar, file:/D:/MavenRes/NewMavenLib/org/apache/tomcat/embed/tomcat-embed-websocket/8.0.36/tomcat-embed-websocket-8.0.36.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/boot/spring-boot-starter-validation/1.3.7.RELEASE/spring-boot-starter-validation-1.3.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/hibernate/hibernate-validator/5.2.4.Final/hibernate-validator-5.2.4.Final.jar, file:/D:/MavenRes/NewMavenLib/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/D:/MavenRes/NewMavenLib/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar, file:/D:/MavenRes/NewMavenLib/com/fasterxml/classmate/1.1.0/classmate-1.1.0.jar, file:/D:/MavenRes/NewMavenLib/com/fasterxml/jackson/core/jackson-databind/2.6.7/jackson-databind-2.6.7.jar, file:/D:/MavenRes/NewMavenLib/com/fasterxml/jackson/core/jackson-annotations/2.6.7/jackson-annotations-2.6.7.jar, file:/D:/MavenRes/NewMavenLib/com/fasterxml/jackson/core/jackson-core/2.6.7/jackson-core-2.6.7.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/spring-web/4.2.7.RELEASE/spring-web-4.2.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/spring-aop/4.2.7.RELEASE/spring-aop-4.2.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/spring-beans/4.2.7.RELEASE/spring-beans-4.2.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/spring-webmvc/4.2.7.RELEASE/spring-webmvc-4.2.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/spring-expression/4.2.7.RELEASE/spring-expression-4.2.7.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/cloud/spring-cloud-starter-eureka/1.1.5.RELEASE/spring-cloud-starter-eureka-1.1.5.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/cloud/spring-cloud-starter/1.1.1.RELEASE/spring-cloud-starter-1.1.1.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/cloud/spring-cloud-context/1.1.1.RELEASE/spring-cloud-context-1.1.1.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/security/spring-security-rsa/1.0.1.RELEASE/spring-security-rsa-1.0.1.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/bouncycastle/bcpkix-jdk15on/1.47/bcpkix-jdk15on-1.47.jar, file:/D:/MavenRes/NewMavenLib/org/bouncycastle/bcprov-jdk15on/1.47/bcprov-jdk15on-1.47.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/cloud/spring-cloud-netflix-core/1.1.5.RELEASE/spring-cloud-netflix-core-1.1.5.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/cloud/spring-cloud-netflix-eureka-client/1.1.5.RELEASE/spring-cloud-netflix-eureka-client-1.1.5.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/eureka/eureka-client/1.4.10/eureka-client-1.4.10.jar, file:/D:/MavenRes/NewMavenLib/org/codehaus/jettison/jettison/1.3.7/jettison-1.3.7.jar, file:/D:/MavenRes/NewMavenLib/stax/stax-api/1.0.1/stax-api-1.0.1.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/netflix-commons/netflix-eventbus/0.3.0/netflix-eventbus-0.3.0.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/archaius/archaius-core/0.7.4/archaius-core-0.7.4.jar, file:/D:/MavenRes/NewMavenLib/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/servo/servo-core/0.10.1/servo-core-0.10.1.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/servo/servo-internal/0.10.1/servo-internal-0.10.1.jar, file:/D:/MavenRes/NewMavenLib/com/sun/jersey/jersey-core/1.19.1/jersey-core-1.19.1.jar, file:/D:/MavenRes/NewMavenLib/com/sun/jersey/jersey-client/1.19.1/jersey-client-1.19.1.jar, file:/D:/MavenRes/NewMavenLib/com/sun/jersey/contribs/jersey-apache-client4/1.19.1/jersey-apache-client4-1.19.1.jar, file:/D:/MavenRes/NewMavenLib/org/apache/httpcomponents/httpclient/4.5.2/httpclient-4.5.2.jar, file:/D:/MavenRes/NewMavenLib/org/apache/httpcomponents/httpcore/4.4.5/httpcore-4.4.5.jar, file:/D:/MavenRes/NewMavenLib/commons-codec/commons-codec/1.9/commons-codec-1.9.jar, file:/D:/MavenRes/NewMavenLib/com/google/inject/guice/4.0/guice-4.0.jar, file:/D:/MavenRes/NewMavenLib/javax/inject/javax.inject/1/javax.inject-1.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/governator/governator-api/1.12.10/governator-api-1.12.10.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/eureka/eureka-core/1.4.10/eureka-core-1.4.10.jar, file:/D:/MavenRes/NewMavenLib/com/amazonaws/aws-java-sdk-core/1.11.18/aws-java-sdk-core-1.11.18.jar, file:/D:/MavenRes/NewMavenLib/com/fasterxml/jackson/dataformat/jackson-dataformat-cbor/2.6.6/jackson-dataformat-cbor-2.6.6.jar, file:/D:/MavenRes/NewMavenLib/com/amazonaws/aws-java-sdk-ec2/1.11.18/aws-java-sdk-ec2-1.11.18.jar, file:/D:/MavenRes/NewMavenLib/com/amazonaws/aws-java-sdk-autoscaling/1.11.18/aws-java-sdk-autoscaling-1.11.18.jar, file:/D:/MavenRes/NewMavenLib/com/amazonaws/aws-java-sdk-sts/1.11.18/aws-java-sdk-sts-1.11.18.jar, file:/D:/MavenRes/NewMavenLib/com/amazonaws/aws-java-sdk-route53/1.11.18/aws-java-sdk-route53-1.11.18.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/governator/governator/1.12.10/governator-1.12.10.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/governator/governator-core/1.12.10/governator-core-1.12.10.jar, file:/D:/MavenRes/NewMavenLib/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar, file:/D:/MavenRes/NewMavenLib/org/codehaus/woodstox/woodstox-core-asl/4.4.1/woodstox-core-asl-4.4.1.jar, file:/D:/MavenRes/NewMavenLib/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar, file:/D:/MavenRes/NewMavenLib/org/codehaus/woodstox/stax2-api/3.1.4/stax2-api-3.1.4.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/cloud/spring-cloud-starter-archaius/1.1.5.RELEASE/spring-cloud-starter-archaius-1.1.5.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/commons-configuration/commons-configuration/1.8/commons-configuration-1.8.jar, file:/D:/MavenRes/NewMavenLib/commons-lang/commons-lang/2.6/commons-lang-2.6.jar, file:/D:/MavenRes/NewMavenLib/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar, file:/D:/MavenRes/NewMavenLib/com/google/guava/guava/18.0/guava-18.0.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/cloud/spring-cloud-starter-ribbon/1.1.5.RELEASE/spring-cloud-starter-ribbon-1.1.5.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/ribbon/ribbon/2.2.0/ribbon-2.2.0.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/ribbon/ribbon-transport/2.2.0/ribbon-transport-2.2.0.jar, file:/D:/MavenRes/NewMavenLib/io/reactivex/rxnetty-contexts/0.4.9/rxnetty-contexts-0.4.9.jar, file:/D:/MavenRes/NewMavenLib/io/reactivex/rxnetty-servo/0.4.9/rxnetty-servo-0.4.9.jar, file:/D:/MavenRes/NewMavenLib/io/reactivex/rxnetty/0.4.9/rxnetty-0.4.9.jar, file:/D:/MavenRes/NewMavenLib/io/netty/netty-codec-http/4.0.27.Final/netty-codec-http-4.0.27.Final.jar, file:/D:/MavenRes/NewMavenLib/io/netty/netty-codec/4.0.27.Final/netty-codec-4.0.27.Final.jar, file:/D:/MavenRes/NewMavenLib/io/netty/netty-handler/4.0.27.Final/netty-handler-4.0.27.Final.jar, file:/D:/MavenRes/NewMavenLib/io/netty/netty-transport-native-epoll/4.0.27.Final/netty-transport-native-epoll-4.0.27.Final.jar, file:/D:/MavenRes/NewMavenLib/io/netty/netty-common/4.0.27.Final/netty-common-4.0.27.Final.jar, file:/D:/MavenRes/NewMavenLib/io/netty/netty-buffer/4.0.27.Final/netty-buffer-4.0.27.Final.jar, file:/D:/MavenRes/NewMavenLib/io/netty/netty-transport/4.0.27.Final/netty-transport-4.0.27.Final.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/ribbon/ribbon-core/2.2.0/ribbon-core-2.2.0.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/ribbon/ribbon-httpclient/2.2.0/ribbon-httpclient-2.2.0.jar, file:/D:/MavenRes/NewMavenLib/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/netflix-commons/netflix-commons-util/0.1.1/netflix-commons-util-0.1.1.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/ribbon/ribbon-loadbalancer/2.2.0/ribbon-loadbalancer-2.2.0.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/netflix-commons/netflix-statistics/0.1.1/netflix-statistics-0.1.1.jar, file:/D:/MavenRes/NewMavenLib/io/reactivex/rxjava/1.1.5/rxjava-1.1.5.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/ribbon/ribbon-eureka/2.2.0/ribbon-eureka-2.2.0.jar, file:/D:/MavenRes/NewMavenLib/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar, file:/D:/MavenRes/NewMavenLib/com/thoughtworks/xstream/xstream/1.4.2/xstream-1.4.2.jar, file:/D:/MavenRes/NewMavenLib/xmlpull/xmlpull/1.1.3.1/xmlpull-1.1.3.1.jar, file:/D:/MavenRes/NewMavenLib/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/cloud/spring-cloud-starter-feign/1.1.5.RELEASE/spring-cloud-starter-feign-1.1.5.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/cloud/spring-cloud-commons/1.1.1.RELEASE/spring-cloud-commons-1.1.1.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/org/springframework/security/spring-security-crypto/4.0.4.RELEASE/spring-security-crypto-4.0.4.RELEASE.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/feign/feign-core/8.16.2/feign-core-8.16.2.jar, file:/D:/MavenRes/NewMavenLib/org/jvnet/animal-sniffer-annotation/1.0/animal-sniffer-annotation-1.0.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/feign/feign-slf4j/8.16.2/feign-slf4j-8.16.2.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/feign/feign-hystrix/8.16.2/feign-hystrix-8.16.2.jar, file:/D:/MavenRes/NewMavenLib/com/netflix/hystrix/hystrix-core/1.5.3/hystrix-core-1.5.3.jar, file:/D:/MavenRes/NewMavenLib/org/hdrhistogram/HdrHistogram/2.1.7/HdrHistogram-2.1.7.jar]

于是我更具类加载器打印出的信息,一个文件夹一个文件夹,回溯上去,最后发现是在D:\MavenRes\NewMavenLib\com\netflix\feign\feign-core\8.16.2这个文件夹下的jar包发生了问题。最后删除原先文件重新下载解决。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值