完美解决 Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal

Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal

完美解决 Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal_第1张图片

网上的解决办法:在pom.xml中添加就行

<dependency>
    <groupId>xml-apisgroupId>
    <artifactId>xml-apisartifactId>
    <version>1.4.01version>
dependency>

我照做了,还是报错!!!

我突然关注到了,我使用thymeleaf的时候,为了降低html5格式检查而添加的一个如下依赖:

它也包含了xml-apis这个解决办法中的依赖。

<dependency>
    <groupId>net.sourceforge.nekohtmlgroupId>
    <artifactId>nekohtmlartifactId>
    <version>1.9.22version>
dependency>

在这里插入图片描述

如上图所示,有两个,我以为冲突了,排除即可!

<dependency>
    <groupId>net.sourceforge.nekohtmlgroupId>
    <artifactId>nekohtmlartifactId>
    <version>1.9.22version>
    <exclusions>
        <exclusion>
            <groupId>xml-apisgroupId>
            <artifactId>xml-apisartifactId>
        exclusion>
    exclusions>
dependency>

但是、依旧报错!!!

最终解决办法:将net.sourceforge.nekohtml移除

只添加它就可以了:

<dependency>
    <groupId>xml-apisgroupId>
    <artifactId>xml-apisartifactId>
    <version>1.4.01version>
dependency>

完美解决了!!!

你可能感兴趣的:(BUG整理)