org.apache.http.entity.ContentType是不是在Apache的了吗? [英] org.apache.http.entity.ContentType is not in Apache anymore?

查看:3327
本文介绍了org.apache.http.entity.ContentType是不是在Apache的了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能因为某些原因导入org.apache.http.entity.ContentType。我已经加入Apache的HTTP 4.3.3:

I can't import org.apache.http.entity.ContentType for some reason. I have added Apache HTTP 4.3.3:

  • 客户端
  • 核心
  • commons- codeC
  • HttpClient的缓存
  • 共享记录
  • httpmime
  • 流利-HC

我本来不导入所有这些,但因为问题仍然存在,现在我所做的这一切,我已经清除我的项目,并重建它

originally I didn't import all of these, but since the problem persists I've done it all now, and I have cleaned my project and rebuilt it

进口org.apache.http.entity.mime.MultipartEntityBuilder;

进口org.apache.http.HttpEntity; 也适用

进口org.apache.http.entity.ContentType; 未发现在所有

我使用的是Android工作室(的IntelliJ),所以我不知道构建路径的答案是有帮助这里。

I am using Android Studio (IntelliJ) so I'm not sure build path answers are helpful here

我也尝试通过摇篮链接导入,但我遇到了一个不同的错误,需要更多的控制权的jar文件自己

I also tried importing via gradle link, but I encountered a different error and need more control over the jar files myself

推荐答案

org.apache.http.entity.ContentType 组织。 apache.httpcomponents:的HttpCore:版本4.3.x 模块。但是这样的 org.apache.http.HttpEntity 。你发现之一,这一事实不是其他很可能意味着他们没有被从v4.3.x JAR拉到研究。阿帕奇HttpCommponents项目搬到了大量的类各地最近。因此,它可以在一个较旧的/不同的版本的HttpCore 的,这是获得拉莫名其妙地找到 HttpEntity ;不具备的ContentType 类的一个版本。你要验证它是寻找 HttpEntity 。有几个方式从那里的依赖是越来越从拉看。

org.apache.http.entity.ContentType is in the org.apache.httpcomponents:httpcore:4.3.x module. But so is org.apache.http.HttpEntity. The fact you are finding one and not the other most likely means they are not being pulled in from the v4.3.x JAR. The Apache HttpCommponents project moved a lot of classes around recently. So it may be finding HttpEntity in an older/different version of httpcore that is getting pulled in somehow; a version that does not have the ContentType class. You'll want to verify where it is finding HttpEntity. There are a few ways to see from where a dependency is getting pulled in from.

选项1 一个最简单的方法就是把你的光标放在类(无论是在import语句或变量声明),并打开快速文件(控制 + <大骨节病>问:或<大骨节病> ^ <大骨节病>Ĵ)。在文件对话框的顶部,它会显示哪些类被发现的依赖性:

Option 1 One of the easiest ways is to put your cursor on the class (either in the import statement or a variable declaration) and open the quick documentation (Ctrl+Q or J). At the top of the documentation dialog, it will show the dependency where the class is found:

选项2 这个选项会告诉你,如果你对你的类路径一类的多个实例。打开的转到类的对话框(控制 + <大骨节病> N 或<大骨节病>⌘ <大骨节病> 0 ),并输入类名(可以完全有资格或没有。你甚至可以paritally输入名称,并使用驼峰搜索)。在被发现,在右边将是其中类发现的类的列表。 右边是从哪个类是从未来的依赖。如果显示一次以上,这意味着它是被拉动多次在不同的罐。发生这种情况(使用构建工具时)如果另一依赖是拉动不同版本的的HttpCore 作为传递依赖。所以,你需要解决这个问题。在我的屏幕截图请注意我有两个不同版本的 org.springframework.http.HttpEntity 类。一位来自春3.2.10,一个来自4.0.6。在这种特殊情况下,那是因为我有一个基于春3.2.x的模块,并在我的项目单独春4.0.x的模块。因此,我与该行,因为他们并不冲突,因为这些是独立的模块。但在大多数情况下,这将是值得关注。

Option 2 This option will show you if you have multiple instances of a class on your class path. Open the Goto Class dialog (Ctrl+N or O) and enter the class name (you can fully qualify or not. You can even paritally enter the name and use camel case search). In the list of classes that are found, to the right will be where the class is found. TO the right is the dependency from which the class is coming from. If it shows more than once, it means that it is being pulled in multiple times in different jars. This can happen (when using a build tool) if another dependency is pulling in a different version of httpcore as a transitive dependency. So you will need to resolve that. Notice in my screen shot I have two different versions of the org.springframework.http.HttpEntity class. One from Spring 3.2.10 and one from 4.0.6. In this particular case it is because I have a Spring 3.2.x based module and a separate Spring 4.0.x module in my project. So I'm OK with that as they do not clash since those are independent modules. But in most cases, that would be cause for concern.

选项3 您还可以展开,并期待在的外部库的在节点的项目的工具窗口,看是否有相关性正在拉两次。

Option 3 You can also expand and look at the External Libraries node in the Project Tool window to see if a dependency is being pulled in twice.

目前还不清楚你的项目是如何配置的。你提到的摇篮,但它似乎更像是一个想后。如果您在使用maven或摇篮,并适当的HttpCore 依赖于你的POM声明或建立文件,请确保您执行重新导入适当的构建工具窗口上,从而正确同步并且该模块被添加到项目的依赖。然后使用以上信息,看看是否有被拉扯在多个版本的的HttpCore 模块。

It's unclear how your project is configured. You mentioned gradle, but it seemed more like an after thought. If you are using maven or gradle, and the proper httpcore dependency is declared in your pom or build file, make sure you perform a reimport on the appropriate build tool window so that it synchronizes properly and that module is added to the project's dependency. Then use the above information to see if you have multiple versions of the httpcore module being pulled in.

这篇关于org.apache.http.entity.ContentType是不是在Apache的了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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