如何在 Grails 中安装和使用 httpbuilder 插件?
最佳答案
将 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
我认为问题在于 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'
}
}
}
我想你需要
mavenRepo "http://repository.codehaus.org"
在存储库部分也是如此。
关于grails - 如何在 grails 中安装和使用 httpbuilder 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7379455/