1. 程式人生 > 其它 >【NoClassDefFoundError】: org/apache/http/util/Args

【NoClassDefFoundError】: org/apache/http/util/Args

搭建SpringCloud微服務架構的時候,遇到的httpClient版本衝突問題,結合其它博文進行了處理

在進行SpringCloud微服務建工搭建溫習的時候,發現之前能正常的執行的服務提供者,報了java.lang.NoClassDefFoundError的錯誤

Caused by: java.lang.NoClassDefFoundError: org/apache/http/util/Args
	at org.apache.http.conn.scheme.Scheme.<init>(Scheme.java:92) ~[httpclient-4.5.3.jar:4.5.3]
	at com.netflix.discovery.shared.transport.jersey.EurekaJerseyClientImpl$EurekaJerseyClientBuilder$MyDefaultApacheHttpClient4Config.createDefaultSslCM(EurekaJerseyClientImpl.java:274) ~[eureka-client-1.6.2.jar:1.6.2]
	at com.netflix.discovery.shared.transport.jersey.EurekaJerseyClientImpl$EurekaJerseyClientBuilder$MyDefaultApacheHttpClient4Config.<init>(EurekaJerseyClientImpl.java:187) ~[eureka-client-1.6.2.jar:1.6.2]
	at com.netflix.discovery.shared.transport.jersey.EurekaJerseyClientImpl$EurekaJerseyClientBuilder.build(EurekaJerseyClientImpl.java:170) ~[eureka-client-1.6.2.jar:1.6.2]
	at com.netflix.discovery.shared.transport.jersey.JerseyEurekaHttpClientFactory$JerseyEurekaHttpClientFactoryBuilder.buildLegacy(JerseyEurekaHttpClientFactory.java:197) ~[eureka-client-1.6.2.jar:1.6.2]
	at com.netflix.discovery.shared.transport.jersey.JerseyEurekaHttpClientFactory$JerseyEurekaHttpClientFactoryBuilder.build(JerseyEurekaHttpClientFactory.java:178) ~[eureka-client-1.6.2.jar:1.6.2]
	at com.netflix.discovery.shared.transport.jersey.JerseyEurekaHttpClientFactory.create(JerseyEurekaHttpClientFactory.java:135) ~[eureka-client-1.6.2.jar:1.6.2]
	at com.netflix.discovery.shared.transport.jersey.Jersey1TransportClientFactories.newTransportClientFactory(Jersey1TransportClientFactories.java:48) ~[eureka-client-1.6.2.jar:1.6.2]
	at com.netflix.discovery.DiscoveryClient.scheduleServerEndpointTask(DiscoveryClient.java:454) ~[eureka-client-1.6.2.jar:1.6.2]
	at com.netflix.discovery.DiscoveryClient.<init>(DiscoveryClient.java:392) ~[eureka-client-1.6.2.jar:1.6.2]
	... 45 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.apache.http.util.Args
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_241]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_241]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[na:1.8.0_241]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_241]
	... 55 common frames omitted

進過一番搜尋,發現大多數相同的報錯的原因都是因為httpClient版本衝突,但檢測了該模組的依賴,發現httpClient版本並不衝突。

後來發現我之前換過maven倉庫,於是換回老的倉庫,發現能正常執行。於是切換新的殘酷之後,對maven倉庫中\org\apache\httpcomponents\httpclient下的包刪除重新下,返現專案正常啟動了


總結

應該還是httpClient版本衝突問題,有衝突解決衝突,如果沒有衝突,重新下載httpClient相關包