问题描述
我得到了下一个常规代码:
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance()
Document xmlDocument = builderFactory.newDocumentBuilder().parse(new FileInputStream(file))
XPath xPath = XPathFactory.newInstance().newXPath()
NodeList nodeList = (NodeList) xPath.compile(xPathQuery).evaluate(xmlDocument,XPathConstants.NODESET)
logger.info(nodeList.getClass())
nodeList.each {
logger.info(it.getClass())
logger.debug("value " + it.getTextContent())
}
如果我在本地运行它,一切正常。 在日志中,我发现我所有的课都没事
logger.info(nodeList.getClass()) /// com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList
logger.info(it.getClass()) /// com.sun.org.apache.xerces.internal.dom.DeferredTextImpl
使用OpenJDK11从Jenkins和从Java -jar运行此代码的外部运行程序运行它,我得到了下一个错误:
没有方法签名:com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList.getTextContent()适用于参数类型:()值:[]
在日志中我发现了
logger.info(nodeList.getClass()) /// com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList
logger.info(it.getClass()) /// com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList
在我的build.gradle文件中,我排除了所有apache.xerces依赖项和xalan依赖项,以防止破坏jdk11库。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)