首页 > 解决方案 > ClassNotFoundException : org.apache.http.util.Args - 如何使用 MultipartEntityBuilder 上传文件?

问题描述

这就是我得到的

org.apache.http.util.Args。Stacktrace 如下: 消息:org.apache.http.util.Args Line | 方法->> 366 | 运行在java.net.URLClassLoader$1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 355 | 运行在'' | 第354章 查找类。. . . . . . . . . . . 在 java.net.URLClassLoader | 423 | java.lang.ClassLoader 中的 loadClass | 48 | . . . . . . . . . . . . . . 在 org.apache.http.entity.mime.content.AbstractContentBod | 155 | 在 org.apache.http.entity.mime.content.StringBody | 121 | 添加文本体。. . . . . . . . . . 在 org.apache.http.entity.mime.MultipartEntityBuilder | 271 | com.org.basepin 中的 $tt__getResponseFromHttpPostServer。用户服务$$ER2a9kvc | 184 | $tt__createRequest 。. . . . . . . 在''| 第437章 $tt__uploadClashImages
在''| 第1325章 呼叫。. . . . . . . . . . . . . 在 com.org.basepin.UserController$_fetchClashReportImages | 第1323章 com.org.basepin.UserController 中的 fetchClashReportImages | 198 | 过滤器。. . . . . . . . . . . . 在 grails.plugin.cache.web.filter.PageFragmentCachingFilt | 63 | grails.plugin.cache.web.filter.AbstractFilter 中的 doFilter | 1110 | 运行工人。. . . . . . . . . . . 在 java.util.concurrent.ThreadPoolExecutor |
603 | 在 java.util.concurrent.ThreadPoolExecutor$Worker 中运行 ^ 722 | 跑 。. . . . . . . . . . . . . . 在 java.lang.Thread

BuildConfig.groovy dependencies{

 compile('org.apache.httpcomponents:httpcore:4.2.4'){
             excludes "commons-codec"
         }
         compile('org.apache.httpcomponents:httpclient:4.1.2'){
             excludes "commons-codec"
         }
         compile('org.apache.httpcomponents:httpmime:4.3'){
             excludes "commons-codec"
         }
         //compile "org.grails.plugins:rest:0.8"

        runtime('org.apache.httpcomponents:httpcore:4.2.4'){
            excludes "commons-codec"
        }
        runtime('org.apache.httpcomponents:httpclient:4.1.2'){
            excludes "commons-codec"
        }
        runtime('org.apache.httpcomponents:httpmime:4.3'){
            excludes "commons-codec"
        }
     }

标签: dependencieshttpclient

解决方案


快速浏览一下,我会假设 httpmime 4.3 使用该 Args 类,并且它期望它由 httpcore 依赖项提供。您不依赖于 httpcore 的 4.3 版本,而这似乎是它被引入的时候。

将您的 httpcore 依赖项更新到 4.3,此错误应该会解决。当您使用它时,我会让所有这三个依赖项都使用相同的版本,否则您可能会看到另一个错误。


推荐阅读