在开发项目中,出现一个错误:The method getTextContent() is undefined for the type Node,解决办法:
网上查大部分是说jdk版本问题,发现不是,
原因由于jdk自带的 rt.jar 包和xml-apis.jar 包出现了冲突,引用优先级的不同导致引用了xml-apis.jar的方法,而xml-apis.jar包是依赖于dom4j包的,解决办法如下:
在项目底下的pom.xml文件,找到dom4j所存在的位置,加上下面一段依赖即可:
<exclusions><exclusion><artifactId>xml-apis</artifactId><groupId>xml-apis</groupId></exclusion></exclusions>
总的为:
<dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.5.9</version> <exclusions><exclusion><artifactId>xml-apis</artifactId><groupId>xml-apis</groupId></exclusion></exclusions></dependency>
这样就不会报The method getTextContent() is undefined for the type Node错误了。