使用httpclient 库发送http请求,提示NoClassDefFoundError: org/apache/commons/logging/LogFactory

使用httpclient 库发送http请求,提示NoClassDefFoundError: org/apache/commons/logging/LogFactory commons-logging jar包已加入,但是在我项目中该jar包的maven配置scope是provided,当我想尝试使用main方法去运行httpClient发送http请求时就会报错;但是当我把我项目运行在jetty上,再去通过httpClient发送http请求就不会报NoClassDefFoundError。如果想在main方法运行httpClient 方法时,需要把commons-logging 的maven 的 scope 改成compile,最后使用jetty运行时再改回来。