美文网首页
使用org.w3c.dom.Element的setTextCon

使用org.w3c.dom.Element的setTextCon

作者: hoxis | 来源:发表于2015-12-31 11:26 被阅读856次

今天在更新项目后进行编译时,出现如下错误一堆:


编译错误编译错误

Google之,在stackoverflow上看到如下的解决方法:

I came here with the same problem. Even worse: I had two projects side by side, both targetting the same JRE (1.6), and one was able to resolve Node.getTextContent() while the other wasn't. I resolved it sort of by accident; I went to project properties | Java Build Path | Order and Export tab, selected the JRE (which was at the bottom of the list) and clicked the "Top" button to move it to the top. My problem went away. It appears that the Node I wanted was hidden by another one. :-\ Maybe this will help with your problem.

大体解决方法就是:
在项目的Java Build Path | Order and Export选项卡中,将JRE System Library选中,并Top置顶。然后再进行编译即可。如图:

top-jre6top-jre6

但是上面并没有给出原因。


其实顺着问题的解决思路想想,肯定是jar出现了冲突所致。于是我就在项目的jar包中找可能含有org.w3c.dom.Element这个类的jar包。既然将JRE的lib进行了置顶,那么就有理由猜测JRE-lib里存在这个类的相关方法。

最终,在rt.jarxml-apis.jar和中找到了。应该就是这两个jar冲突所致,由于引用优先级的不同导致引用了xml-apis.jar中的方法。

其实在pom.xml中并没有这个jar的直接引用,在Dependency Hierarchy视图中搜索xml-apis可以发现,它其实是由于dom4j的依赖而引入的。如图:

Dependency  HierarchyDependency Hierarchy

解决方法:右击该jar,选择exclude maven artifact,确认并保存,重新编译即可:

exclude maven artifactexclude maven artifact

最终的pom.xml中只是在dom4j<dependency>中多了这么一段<exclusions>

<dependency>
    <groupId>dom4j</groupId>
    <artifactId>dom4j</artifactId>
    <version>1.6.1</version>
    <exclusions>
        <exclusion>
            <artifactId>xml-apis</artifactId>
            <groupId>xml-apis</groupId>
        </exclusion>
    </exclusions>
</dependency>

参考:
http://stackoverflow.com/questions/5534864/compilation-error-in-node-gettextcontent-for-jdk-6
http://www.educity.cn/wenda/364108.html


如果觉得有用,欢迎关注我的微信,有问题可以直接交流:

你的关注是对我最大的鼓励!你的关注是对我最大的鼓励!

相关文章

  • 使用org.w3c.dom.Element的setTextCon

    今天在更新项目后进行编译时,出现如下错误一堆: Google之,在stackoverflow上看到如下的解决方法:...

  • iconfont的使用(下载使用)

    1、下载文件 2、在生命周期中引入项目 beforeCreate () { var domModule = ...

  • Gson的使用--使用注解

    Gson为了简化序列化和反序列化的过程,提供了很多注解,这些注解大致分为三类,我们一一的介绍一下。 自定义字段的名...

  • 记录使用iframe的使用

    默认记录一下----可以说 这是我第一次使用iframe 之前都没有使用过; 使用方式: 自己开发就用了这几个属...

  • with的使用

    下面例子可以具体说明with如何工作: 运行代码,输出如下

  • this的使用

    什么是this? this是一个关键字,这个关键字总是返回一个对象;简单说,就是返回属性或方法“当前”所在的对象。...

  • this的使用

    JS中this调用有几种情况 一:纯粹的函数调用 这是函数的最通常用法,属于全局性调用,因此this就代表全局对象...

  • ==的使用

    积累日常遇到的编码规范,良好的编码习惯,持续更新。。。 日常使用==用于判断的时候,习惯性将比较值写前面,变量写后...

  • this的使用

    1.默认绑定,就是函数立即执行。 函数立即执行就是指向window,但是如果是node环境,就是指向全局conso...

  • %in% 的使用

    写在前面:From 生信技能书向量难点之一:%in% 难点 (1)== 与 %in% 的区别== 强调位置,x和对...

网友评论

      本文标题:使用org.w3c.dom.Element的setTextCon

      本文链接:https://www.haomeiwen.com/subject/sgnihttx.html