如何从 grails 的类路径中获取 4.0 版本的 httpclient

发布于 2024-12-13 02:44:06 字数 548 浏览 5 评论 0原文

我正在使用 Grails 1.3.7,无法弄清楚如何从我的类路径中获取 httpclient 4.0 版本(支持 4.1)。我需要这样做是因为该插件依赖于 4.1 中使用的无参数构造函数。

运行 grails 'dependency-report',看起来 4.1 应该是运行时使用的版本。如果我把东西打包成一个 .war ,那就是这样。然而,由于某种原因,当使用 run-app 时,4.0 版本仍然最终出现在类路径上。请注意,它(正确地)在编译时用于某些 grails 内部结构,并且不知何故它仍然出现在我的类路径中。

->我能否弄清楚 4.0 .jar 到底来自哪里并最终出现在我的类路径上并阻止它发生(通过 run-app 运行时所有 .jar 放在哪里?)

->我可以告诉 grails 使用 4.1 而不是 4.0 进行内部编译(在本例中是 org.codehaus.groovy.modules.http-builder 模块的 http-builder 吗?)可以说不是最好的解决方案,但我会接受它,因为每次我想测试它时,将所有内容都打包到 .war 中并不令人愉快。

帮助将不胜感激。

I am using Grails 1.3.7 and cannot figure out how to get version 4.0 of httpclient off of my classpath (in favour of 4.1). I need to do this because of a no-args constructer used in 4.1 that the plugin relies on.

Running a grails 'dependency-report', it appears that 4.1 should be the one being used at runtime. And it IS, if I package things up into a .war. HOWEVER version 4.0 is still ending up on the classpath when using run-app for some reason. Note it is (correctly) being used at compile time for some grails internals, and somehow it is still ending up on my classpath.

-> Can I figure out where exactly that 4.0 .jar is coming from and ending up on my classpath and stop it from happening (where are all the .jars put when running via run-app?)

-> Can I tell grails to compile with 4.1 instead of 4.0 for its internals (in this case the http-builder by org.codehaus.groovy.modules.http-builder module?) Arguable not the best solution but I'll take it, as packaging everything into a .war every time I want to test it is not pleasant.

Help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小清晰的声音 2024-12-20 02:44:06

我刚刚经历了同样的事情,将以下内容添加到您的 BuildConfig.groovy

dependencies {        
        build 'org.apache.httpcomponents:httpcore:4.1.2' 
        build 'org.apache.httpcomponents:httpclient:4.1.2' 
        runtime 'org.apache.httpcomponents:httpcore:4.1.2'
        runtime 'org.apache.httpcomponents:httpclient:4.1.2'
} 

干杯

Lee

I just went through the same thing, add the following to your BuildConfig.groovy

dependencies {        
        build 'org.apache.httpcomponents:httpcore:4.1.2' 
        build 'org.apache.httpcomponents:httpclient:4.1.2' 
        runtime 'org.apache.httpcomponents:httpcore:4.1.2'
        runtime 'org.apache.httpcomponents:httpclient:4.1.2'
} 

cheers

Lee

简单 2024-12-20 02:44:06

您可以通过在 BuildConfig.groovy 中添加排除行来从类路径中获取 httpclient 4.0。使用 grails dependency-report 命令找出哪个插件将其声明为依赖项。

一旦找到哪个包含它,您可以将其排除在 BuildConfig.groovy 的插件部分中。例子:

插件 {
    编译 ':other-plugin:1.0.0' // other-plugin 依赖于 httpclient 4.1
    compile(':aws:1.2.12.2') { // aws 插件依赖于 httpclient:3.1
        排除“httpclient”
    }
}

依赖 httpclient 4.1 中无参数构造函数的插件应将其声明为依赖项。如果没有,您应该向插件作者提出问题。要解决此问题,您可以按照上面 leebutts 的描述在依赖项部分中列出 httpclient 4.1。

You can get httpclient 4.0 off of the classpath by adding an excludes line in BuildConfig.groovy. Figure out which plugin is declaring it as a dependency by using the grails dependency-report command.

Once you find which one included it, you can exclude it in the plugins section of BuildConfig.groovy. Example:

plugins {
    compile ':other-plugin:1.0.0' // other-plugin depends on httpclient 4.1
    compile(':aws:1.2.12.2') { // aws plugin depends on httpclient:3.1
        excludes 'httpclient'
    }
}

The plugin that relies on the no-arg constructor in httpclient 4.1 should declare it as a dependency. If it does not you should open an issue with the author of the plugin. To workaround this, you can list httpclient 4.1 in the dependencies section as leebutts describes above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文