javax.xml.stream 包可从多个模块访问:<unnamed>、java.xml

jan*_*z j 6 java compiler-errors java-module

我有编译错误:The package javax.xml.stream is accessible from more than one module: <unnamed>, java.xml。应用程序已maven install成功构建,但它不作为 java 应用程序运行。

CTRL + SHIFT + T 显示该javax.xml.stream包是 JDK-11(模块路径)和(类路径)的一部分stax-apistax-api是父模块的依赖项,无法删除。此问题出现在 Eclipse 2019-12、2020-03、2020-06 和 IntelliJ 以及不同版本的 Java 11 上。

到目前为止,我尝试排除 child 中的所有依赖项的 javax.xml.stream <exclude>javax.xml.stream</exclude> 但没有成功。

我该如何解决这个问题?

Mar*_*r-Z 1

到目前为止,我尝试排除 child 中的所有依赖项的 javax.xml.stream <exclude>javax.xml.stream</exclude>但没有成功。

不确定您是如何进行排除的?我想说它应该在 pom.xml 中完成。与此类似:

<dependency>
    <groupId>A_GROUP_ID</groupId>
    <artifactId>AN_ARTIFACT_ID</artifactId>
    <exclusions>
        <exclusion>
            <groupId>javax.xml.stream</groupId>
            <artifactId>stax-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)