gpt4 book ai didi

Groovy Grape 处理依赖解析

转载 作者:行者123 更新时间:2023-12-02 05:16:01 25 4
gpt4 key购买 nike

我正在尝试使用org.xhtmlrenderer:core-renderer:R8pre2在常规脚本中,但我收到链接错误:

Caught: java.lang.LinkageError: loader constraint violation in interface 
itable initialization: when resolving method
"org.apache.xerces.dom.NodeImpl.getOwnerDocument()Lorg/w3c/dom/Document;"
the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the
current class, org/apache/xerces/dom/NodeImpl, and the class loader (instance of
<bootloader>) for interface org/w3c/dom/Node have different Class objects for
the type getOwnerDocument used in the signature

我已经用谷歌搜索了很多,找到了很多像这样的答案:

Dealing with "Xerces hell" in Java/Maven?

XercesImpl in conflict with JavaSE 6's internal xerces implementation. Both are needed... what can be done?

因此,一种解决方案可能是使用 javas endorsed解决冲突的机制,但我想让我的脚本独立于这样的“解决方法”。该脚本应该开箱即用。

接下来我尝试的是排除这样的正确依赖

@Grapes([
@Grab('org.xhtmlrenderer:core-renderer:R8pre2'),
@GrabExclude('xml-apis:xml-apis')
])

但没有成功...

有什么想法吗?

PS:这是创建错误的脚本:

@Grapes([
@Grab('org.xhtmlrenderer:core-renderer:R8pre2'),
])
import org.w3c.dom.Document
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
def dbf = DocumentBuilderFactory.newInstance()
DocumentBuilder builder = dbf.newDocumentBuilder()
Document doc = builder.parse(new ByteArrayInputStream("<html></html>".getBytes()))

最佳答案

感谢@dmahapatro,我检查了我的配置,发现我很久以前在 {usrhome}/.groovy 中删除了一些 jar。删除了这些,现在一切都像魅力一样......

关于Groovy Grape 处理依赖解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23021082/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com