java 导入 org.apache.commons.httpclient.*

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11513677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 05:23:31  来源:igfitidea点击:

import org.apache.commons.httpclient.*

java

提问by Jury A

I use a code that imports the following package:

我使用导入以下包的代码:

import org.apache.commons.httpclient.*;

I use eclipse. I went to http://hc.apache.org/downloads.cgi& I downloaded the Jar files, I added them to my project. Still eclipse making an error for this.

我使用日食。我去了http://hc.apache.org/downloads.cgi& 我下载了 Jar 文件,我将它们添加到我的项目中。仍然eclipse为此犯了一个错误。

Exception in thread "main" java.lang.Error: Unresolved compilation problems: HttpClient cannot be resolved to a type

线程“main”中的异常 java.lang.Error:未解决的编译问题:HttpClient 无法解析为类型

What is the problem?

问题是什么?

回答by Thilo

If you are using the latest (4.x) version of these modules, they have been refactored a lot. For example, the package name is now org.apache.http.client. Old sample code will have to be modified. Look at the Javadocsand the Quickstartfor the new project.

如果您使用的是这些模块的最新 (4.x) 版本,它们已经被重构了很多。例如,包名称现在是org.apache.http.client必须修改旧的示例代码。查看新项目的JavadocsQuickstart

The (discouraged) alternative would be to get the old (3.x) version.

(不鼓励的)替代方法是获取旧的 (3.x) 版本。

回答by Reimeus

I would recommend using Mavenfor managing your 3rd party dependencies. It takes care of jar files & all related dependencies.

我建议使用Maven来管理您的 3rd 方依赖项。它负责处理 jar 文件和所有相关的依赖项。

The maven dependency for httpclient is:

httpclient 的 maven 依赖项是:

 <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.2.1</version>
    <scope>compile</scope>
  </dependency>