简体   繁体   English

排除依赖无助于修复“package org.w3c.dom 可以从多个模块访问:<unnamed> , java.xml”</unnamed>

[英]Excluding dependency does not help to fix “The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml”

When trying to setup a project with a Java version > 9 I came across a problem with dependencies and the Java module system.在尝试使用 Java 版本 > 9 设置项目时,我遇到了依赖项和 Java 模块系统的问题。 I know that there are some posts regarding this topic (eg this one or this one ), but the solutions (exclude packages from dependencies) don't seem to help in my case.我知道有一些关于这个主题的帖子(例如this onethis one ),但解决方案(从依赖项中排除包)似乎对我没有帮助。
On some imports related to XML parsing, I get the following error The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml On some imports related to XML parsing, I get the following error The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml

I used the "Open Type" dialog and found that there are in fact two providers for eg org.w3c.dom.Document.我使用了“打开类型”对话框,发现实际上有两个提供程序,例如 org.w3c.dom.Document。 org.w3c.dom.Document 的两个提供者

This rmlmapper-4.9.1.jar is currently the only maven dependency in my project and I tried to exclude xml-apis as suggested here .这个rmlmapper-4.9.1.jar目前是我项目中唯一的 maven 依赖项,我尝试按照此处的建议排除 xml-apis。 I also added org.w3c.dom as you can see.如您所见,我还添加了 org.w3c.dom。

<dependencies>
    <dependency>
        <groupId>be.ugent.rml</groupId>
        <artifactId>rmlmapper</artifactId>
        <version>4.9.1</version>
        <exclusions>
            <exclusion>
                <groupId>xml-apis</groupId>
                <artifactId>xml-apis</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.w3c</groupId>
                <artifactId>dom</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

Unfortunately, this doesn't help and the error persists.不幸的是,这无济于事,错误仍然存在。 Note that I can build the project but get errors at runtime.请注意,我可以构建项目,但在运行时会出错。 Am I excluding the wrong packages?我是否排除了错误的包裹? I couldn't find a package providing org.w3c.dom using mvn dependency:tree so how can I find the packages that need to be excluded?我找不到使用mvn dependency:tree提供org.w3c.dom的 package 那么如何找到需要排除的包?

From the Eclipse snapshot you provide, it seems the package org.w3c.dom is embedded in the rmlmapper dependency Jar itself (the Jar is probably bundling its own dependencies in it). From the Eclipse snapshot you provide, it seems the package org.w3c.dom is embedded in the rmlmapper dependency Jar itself (the Jar is probably bundling its own dependencies in it). Therefore the exclusion will not work as it only excludes transitive dependencies (not bundled packages).因此exclusion将不起作用,因为它只排除传递依赖项(而不是捆绑包)。 Even though it's possible to exclude the package , another approach is to exclude the java.xml module with the --limit-modules option as answered here .即使可以排除 package ,另一种方法是排除java.xml模块, 这里回答了--limit-modules选项。 Note that you might have to do this with other modules if rmlmapper also bundles other JDK classes.请注意,如果rmlmapper还捆绑了其他 JDK 类,您可能必须对其他模块执行此操作。

Either way, the best solution is to contact the owner of the rmlmapper library and let them know of the issue on Java 9+, as maybe they did not upgrade their project to support that version.无论哪种方式,最好的解决方案是联系rmlmapper库的所有者,让他们知道 Java 9+ 上的问题,因为他们可能没有升级他们的项目以支持该版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 package org.w3c.dom 可以从多个模块访问:<unnamed> , java.xml</unnamed> - The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml package org.w3c.dom 可以从多个模块访问:<unnamed> , java.xml ~ 查找和排除依赖</unnamed> - The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml ~ Find and exclude dependency 关于“可以从多个模块访问包 org.w3c.dom 的具体问题:<unnamed> ,java.xml&quot; - Specific question concerning "The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml" 包 javax.xml.stream 可以从多个模块访问:<unnamed> , java.xml - The package javax.xml.stream is accessible from more than one module: <unnamed>, java.xml package javax.xml.namespace 可以从多个模块访问:<unnamed> , eclipse 网络服务中的 java.xml</unnamed> - The package javax.xml.namespace is accessible from more than one module: <unnamed>, java.xml in eclipse webservice gwt-user.jar 和 Java 11 - package javax.xml.parsers 可以从多个模块访问:<unnamed> , java.xml</unnamed> - gwt-user.jar with Java 11 - The package javax.xml.parsers is accessible from more than one module: <unnamed>, java.xml 可从多个模块访问的包:<unnamed> - Package accessible from more than one module: <unnamed> 春季启动2。Java10。JUnit。 可以从多个模块中访问org.slf4j软件包: <unnamed> ,slf4j.api - Spring boot 2. Java 10. JUnit. The package org.slf4j is accessible from more than one module: <unnamed>, slf4j.api 在XML org.w3c.dom中阅读特殊字符 - Reading special Charanters in XML org.w3c.dom 为什么org.w3c.dom解析我的xml错误? - Why is org.w3c.dom parsing my xml wrong?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM