如何在grails中安装和使用httpbuilder插件

use*_*772 3 grails groovy httpbuilder

如何在Grails中安装和使用httpbuilder插件?

ata*_*lor 28

将httpbuilder 0.5.1添加到应用程序依赖项将导致错误.特别是,你会得到这样的错误:

java.lang.LinkageError: loader constraint violation: when resolving overridden method "org.apache.xerces.jaxp.SAXParserImpl.getParser()Lorg/xml/sax/Parser;" the class loader (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the current class, org/apache/xerces/jaxp/SAXParserImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type org/xml/sax/Parser used in the signature
Run Code Online (Sandbox Code Playgroud)

我认为问题在于httpbuilder将其编译时依赖项导出为运行时依赖项.一个简单的解决方法是在您的BuildConfig.groovy:中声明这样的依赖关系:

grails.project.dependency.resolution = {
    ...
    dependencies {
        runtime('org.codehaus.groovy.modules.http-builder:http-builder:0.5.1') {
            excludes 'xalan'
            excludes 'xml-apis'
            excludes 'groovy'
        }
    }
}   
Run Code Online (Sandbox Code Playgroud)

我认为你也需要mavenRepo "http://repository.codehaus.org"在存储库部分.


Rob*_*ska 5

有一个REST客户端插件:

  • 我没有阅读过这些文档或曾经使用过这个插件,但是我没有受过教育的猜测是将`get`替换为`post` (4认同)