idea插件开发dom4j报错:SAXParser cannot be cast to class org.xml.sax.XMLReader

手打不易,如果转摘,请注明出处!

注明原文: https://blog.csdn.net/q258523454/article/details/145512328


dom4j报错

idea插件使用到了dom4j依赖,但是报错:

I will print the stack trace then carry on using the default SAX parser

Caught exception attempting to use SAX to load a SAX XMLReader

java.lang.ClassCastException: class org.apache.xerces.parsers.SAXParser cannot be cast to class org.xml.sax.XMLReader (org.apache.xerces.parsers.SAXParser is in unnamed module of loader com.intellij.util.lang.PathClassLoader @5ba23b66; org.xml.sax.XMLReader is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @63326c11)

I will print the stack trace then carry on using the default SAX parser
Caught exception attempting to use SAX to load a SAX XMLReader 
java.lang.ClassCastException: class org.apache.xerces.parsers.SAXParser cannot be cast to class org.xml.sax.XMLReader (org.apache.xerces.parsers.SAXParser is in unnamed module of loader com.intellij.util.lang.PathClassLoader @5ba23b66; org.xml.sax.XMLReader is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @63326c11)

原因

这是因为依赖冲突了,IntelliJ IDEA 新版已经自带了

<dependency>

<groupId>xml-apis</groupId>

<artifactId>xml-apis</artifactId>

<version>xxx</version>

</dependency>

解决

我们只需要排除这个依赖即可

build.gradle 文件中添加(新版gradle):

configurations.configureEach {
    exclude group: 'xml-apis', module: 'xml-apis'
}

或者(旧版本gradle)

configurations.all {
    exclude group: 'xml-apis', module: 'xml-apis'
}

重新运行即可!

相关推荐
硬件人某某某11 分钟前
微信小程序~电器维修系统小程序
java·ajax·微信小程序·小程序
猿java13 分钟前
MySQL 如何实现主从复制?
java·后端·mysql
martian66524 分钟前
【Java基础篇】——第4篇:Java常用类库与工具类
java·开发语言
荷碧TongZJ26 分钟前
Jupyter Notebook 6/7 设置代码补全
ide·python·jupyter
violin-wang1 小时前
Intellij IDEA调整栈内存空间大小详细教程,添加参数-Xss....
java·ide·intellij-idea·xss·栈内存·栈空间
在下陈平安1 小时前
java-LinkedList源码详解
java·开发语言
黑客老李1 小时前
一次使用十六进制溢出绕过 WAF实现XSS的经历
java·运维·服务器·前端·sql·学习·xss
接着奏乐接着舞。1 小时前
【vscode源码】如何编译运行vscode及过程中问题解决
ide·vscode·编辑器
Mao.O1 小时前
IDEA编写SpringBoot项目时使用Lombok报错“找不到符号”的原因和解决
java·spring boot·intellij-idea·lombok
iCheer-xu2 小时前
VSCODE内使用Jupyter模式,运行backtrader不展示图片、图片尺寸无法自定义的处理方案
ide·vscode·jupyter