Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal
网上的解决办法:在pom.xml中添加就行
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
我照做了,还是报错!!!
我突然关注到了,我使用thymeleaf的时候,为了降低html5格式检查而添加的一个如下依赖:
它也包含了xml-apis这个解决办法中的依赖。
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
如上图所示,有两个,我以为冲突了,排除即可!
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
但是、依旧报错!!!
最终解决办法:将net.sourceforge.nekohtml移除
只添加它就可以了:
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
完美解决了!!!