在我的一个应用程序中,我必须将 geb 与 grails 一起使用。我安装了 geb 插件并添加了依赖 selenium 独立 jar。
现在的问题是在我清理或编译时出现如下错误
交互模式退出并出现错误:加载程序约束冲突:解析覆盖方法时 "org.apache.xerces.jaxp.SAXParserImpl.getXMLReader()Lorg/xml/sax/XMLReader;"
类加载器 (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader)
当前类(class)的org/apache/xerces/jaxp/SAXParserImpl,
及其父类(super class)加载器( instance of <bootloader>
)对于 org/xml/sax/XMLReader
类型具有不同的 Class 对象在签名中使用(使用 --stacktrace 查看完整跟踪)
最佳答案
排除 Selenium 对 xml-apis
的传递依赖像这样在你的BuildConfig.groovy
:
dependencies {
test("org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion") {
exclude "xml-apis"
}
test "org.codehaus.geb:geb-spock:$gebVersion"
test "org.codehaus.geb:geb-junit4:$gebVersion"
}
见 this example project更多细节。
关于Grails --- 加载器约束违规,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12618704/