原因说明:项目原来是基于jdk8构建的,现在升级到jdk11, 由于jdk9加入的新功能module-info.java造成出现上面的异常。在eclipse中,项目->properties-> Java Build Path -> Libraries 内,可以看到两个path路径【Modulepath】和【Classpath】, 这与原来jdk8的不同.
使用Ctr + Shift + T 查询报错类,同包名的在哪些包里。
在pom.xml文件屏蔽所有依赖【xml-apis】的包,如下
<!--
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
-->
<!-- 依赖 xml-apis 的包 开始 -->
<exclusion>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
</exclusion>
<exclusion>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
</exclusion>
<exclusion>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</exclusion>
<!-- 依赖 xml-apis 的包 结束 -->
<!-- 其他会造成 javax.xml 引入问题的包 -->
<exclusion>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</exclusion>