我可以在没有 Commons-logging.jar 的情况下使用 Apache HTTPClient [英] Can I use Apache HTTPClient without Commons-logging.jar

查看:34
本文介绍了我可以在没有 Commons-logging.jar 的情况下使用 Apache HTTPClient的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的项目中使用 Apache HTTPClient.这里不需要此应用程序的任何日志记录.那么我可以在没有 Commons-logging.jar 的情况下使用 HTTPClient 吗?否则会给我的分发包带来额外的不必要的负担.

I'm trying to user Apache HTTPClient in my project. Here does not required any logging for this application. So Can I use HTTPClient without Commons-logging.jar. Otherwise it will be a extra unnecessary burden for my distribution package.

推荐答案

是的,你可以.正如 Hannes 建议的那样 - 这是我自己的 HttpClient maven 设置:

Yes you can. As Hannes suggested - here is my own HttpClient maven setup:

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.3.1</version>
    <exclusions>
        <exclusion>
            <artifactId>commons-logging</artifactId>
            <groupId>commons-logging</groupId>
        </exclusion>
    </exclusions>
</dependency>

接下来,由于common-logging确实是一个运行时依赖,你需要为commons-logging定义SLF4J桥:

Next, since common-logging is indeed a runtime dependency, you will need to define the SLF4J bridge for commons-logging:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>1.7.5</version>
</dependency>

最后,您当然需要有一个有效的 SLF4J 配置——这是我的:

And finally, you will of course need to have a valid SLF4J configuration - here is mine:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.5</version>
</dependency>
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.0.11</version>
</dependency>

希望这会有所帮助.

这篇关于我可以在没有 Commons-logging.jar 的情况下使用 Apache HTTPClient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆