Loading

WebMagic 启动例子报错

报错内容:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager
	at us.codecraft.webmagic.downloader.HttpClientDownloader.<init>(HttpClientDownloader.java:38)
	at us.codecraft.webmagic.Spider.initComponent(Spider.java:280)
	at us.codecraft.webmagic.Spider.run(Spider.java:305)
	at us.codecraft.webmagic.model.samples.QQMeishi.main(QQMeishi.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.HttpClientConnectionManager
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 4 more

Process finished with exit code 1

原因:

不详,菜鸟一个,对于Maven还不熟练,在webmagic-parent/pom.xml中明明已经写上了版本号。

解决方法:

在webmagic-core/pom.xml中对httpclient指定版本号,并更新。

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.6</version>
</dependency> 
posted @ 2019-02-27 10:53  BasilGuo  阅读(565)  评论(0编辑  收藏  举报