org.apache.http.entity.ContentType 不再在 Apache 中了吗?

2023-12-21

由于某种原因,我无法导入 org.apache.http.entity.ContentType。我添加了 Apache HTTP 4.3.3:

  • client
  • core
  • 公共编解码器
  • httpclient 缓存
  • 公共日志记录
  • httpmime
  • 流利-hc

最初我没有导入所有这些,但由于问题仍然存在,我现在已经完成了所有这些,并且我已经清理了我的项目并重建了它

import org.apache.http.entity.mime.MultipartEntityBuilder; works

and

import org.apache.http.HttpEntity;也有效

but

import org.apache.http.entity.ContentType;根本没有找到

我正在使用 Android Studio (IntelliJ),所以我不确定构建路径答案在这里是否有帮助

我也尝试通过 gradle 链接导入,但遇到了不同的错误,需要自己对 jar 文件进行更多控制


org.apache.http.entity.ContentType在里面org.apache.httpcomponents:httpcore:4.3.x模块。但也是如此org.apache.http.HttpEntity。您找到一个而不是另一个的事实很可能意味着它们没有从 v4.3.x JAR 中提取。 Apache HttpCommponents 项目最近移动了很多类。所以可能会发现HttpEntity在较旧的/不同的版本中httpcore不知何故,它被拉进来了;没有的版本ContentType班级。您需要验证它在哪里找到HttpEntity。有几种方法可以查看从何处引入依赖项。

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:

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. enter image description here 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.

Option 3您还可以展开并查看外部库中的节点Project用于查看依赖项是否被拉入两次的工具窗口。

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 enter image description here 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.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

org.apache.http.entity.ContentType 不再在 Apache 中了吗? 的相关文章

  • Git 无法识别重命名和修改的包文件

    我有一个名为的java文件package old myfile java 我已经通过 git 提交了这个文件 然后我将我的包重命名为new所以我的文件在package new myfile java 我现在想将此文件重命名 和内容更改 提交
  • Java 数组的最大维数

    出于好奇 在 Java 中数组可以有多少维 爪哇language不限制维数 但是JavaVM规范将维度数限制为 255 例如 以下代码将无法编译 class Main public static void main String args
  • Android Studio - 值必须 ≥ 0

    我在 Android Studio 中收到与光标有关的错误 我的代码中有以下行 String data cursor getString cursor getColumnIndex columnIndex columnIndex 被传递到该
  • java.lang.IllegalArgumentException:找不到片段的 id 0x1020002 (android:id/content) 的视图

    我正在尝试从一个片段移动到另一个片段 它在片段事务期间显示以下错误 java lang IllegalArgumentException No view found for id 0x1020002 android id content f
  • Spring Security OAuth2简单配置

    我有一个简单的项目 需要以下简单的配置 我有一个 密码 grant type 这意味着我可以提交用户名 密码 用户在登录表单中输入 并在成功时获得 access token 有了该 access token 我就可以请求 API 并获取用户
  • BottomSheetDialog get Behavour 始终返回 null

    我与底部表单对话框我必须获得行为才能设置setBottomSheetCallback 来处理一些事情 As 谷歌说 https android developers googleblog com 2016 02 android suppor
  • Espresso 和 Proguard 的 Java.lang.NoClassDefFoundError

    我对 Espresso 不太有经验 但我终于成功地运行了它 我有一个应用程序需要通过 Proguard 缩小才能处于 56K 方法之下 该应用程序以 3 秒的动画开始 因此我需要等到该动画结束才能继续 这就是我尝试用该方法做的事情waitF
  • 如何在 Eclipse Java 动态 Web 项目中使用 .properties 文件?

    我正在 Eclipse 中开发动态 Web 项目 我创建了一个 properties 文件来存储数据库详细信息 用户名 密码等 我通过右键单击项目和 New gt File 添加它 我使用了Java util包Properties类 但它不
  • 尝试使用等于“是”或“否”的字符串变量重新启动 do-while 循环

    计算行程距离的非常简单的程序 一周前刚刚开始 我有这个循环用于解决真或假问题 但我希望它适用于简单的 是 或 否 我为此分配的字符串是答案 public class Main public static void main String a
  • 解析输入,除了 System.in.read() 之外不使用任何东西

    我很难找到具体的细节System in read 有效 也许有人可以帮助我 似乎扫描仪会更好 但我不允许使用它 我被分配了一个任务 我应该以 Boolean Operator Boolean 的形式读取控制台用户输入 例如T F 或 T T
  • onBackPressed 隐藏 不破坏 Activity

    我知道如何取消后退按键 以便活动 主窗口保持可见 public void onBackPressed return 我的目标是隐藏该活动 但是 在没有完成它的情况下 您如何在 onBackPressed 事件中做到这一点 即我想达到 onP
  • 为什么java中的for-each循环中需要声明变量

    for 每个循环的通常形式是这样的 for Foo bar bars bar doThings 但如果我想保留 bar 直到循环结束 我可以not使用 foreach 循环 Foo bar null Syntax error on toke
  • NoClassDefFoundError:无法解析:Landroid/support/v7/appcompat/R$styleable

    新手尝试完成 Google 提供的我的第一个应用程序教程 在这个致命异常的过程中 我确实导入了很多随机包来消除许多事情的 无法解析 错误 例如 ActionBarActivity EditText Fragment LayoutInflat
  • android httprequest java.net.UnknownHostException

    我想用android发出http请求 是使用这个 void testHTTP HttpClient httpClient new DefaultHttpClient HttpUriRequest request new HttpPost h
  • JVM:是否可以操作帧堆栈?

    假设我需要执行N同一线程中的任务 这些任务有时可能需要来自外部存储的一些值 我事先不知道哪个任务可能需要这样的值以及何时 获取速度要快得多M价值观是一次性的而不是相同的M值在M查询外部存储 注意我不能指望任务本身进行合作 它们只不过是 ja
  • JSON 到 hashmap (杰克逊)

    我想将 JSON 转换为 HashMapJackson http jackson codehaus org 这是我的 JSON String json Opleidingen name Bijz trajecten zorg en welz
  • 在 Honeycomb Android 3.0 中显示 Action Bar 菜单项的图标

    我正在使用 Honeycomb android 3 0 开发 Android 应用程序 我正在尝试在 Action Bar 中显示菜单 菜单有一个图标和标题 当我们单击菜单项时 它会以下拉列表的形式显示其项目 它是下拉列表中带有项目名称但不
  • Hibernate 和可序列化实体

    有谁知道是否有一个框架能够从实体类中剥离 Hibernate 集合以使它们可序列化 我查看了 BeanLib 但它似乎只进行实体的深层复制 而不允许我为实体类中的集合类型指定实现映射 BeanLib 目前不适用于 Hibernate 3 5
  • 直接使用从密钥库加载的 SecretKey 时,密钥用户未经过身份验证

    我正在尝试使用 Cipher 和在 KeyStore 中加载的 SecretKey 来加密数据 但总是收到此错误 导致 android security KeyStoreException 关键用户未经过身份验证 我尝试自己创建 Secre
  • 安卓的限制

    我需要构建一个应用程序 该应用程序拍摄相机图像并将其上传到网络 在网络上进行一些处理并返回真 假 我在这方面遇到了一些问题 希望得到澄清 1 我的应用程序有什么方法可以知道 Android 相机捕获的图像吗 我从这里明白了什么 Androi

随机推荐