java 9未命名模块在调试时(使用IntelliJ)从两者中读取软件包[X] [英] java 9 unnamed module reads package [X] from both ... while debugging (with IntelliJ)

查看:157
本文介绍了java 9未命名模块在调试时(使用IntelliJ)从两者中读取软件包[X]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我有一个使用多个第三方库的程序包.让我们看一下依赖树:

In my project I have a package that uses several 3rd party libraries. Let's have a look at the dependency tree:

[INFO] +- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.apache.directory.studio:org.apache.commons.collections:jar:3.2.1:compile
[INFO] |  \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- xerces:xercesImpl:jar:2.11.0:compile
[INFO] |  \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] +- org.apache.cxf:cxf-rt-bindings-soap:jar:3.2.2:compile
[INFO] |  +- org.apache.cxf:cxf-core:jar:3.2.2:compile
[INFO] |  |  +- com.fasterxml.woodstox:woodstox-core:jar:5.0.3:compile
[INFO] |  |  |  \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[INFO] |  |  \- org.apache.ws.xmlschema:xmlschema-core:jar:2.2.3:compile
[INFO] |  +- org.apache.cxf:cxf-rt-wsdl:jar:3.2.2:compile
[INFO] |  |  +- wsdl4j:wsdl4j:jar:1.6.3:compile
[INFO] |  |  \- org.ow2.asm:asm:jar:5.2:compile
[INFO] |  \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:3.2.2:compile
[INFO] +- org.apache.wss4j:wss4j-ws-security-common:jar:2.2.1:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.22:compile
[INFO] |  +- org.apache.santuario:xmlsec:jar:2.1.1:compile
[INFO] |  |  \- commons-codec:commons-codec:jar:1.10:compile
[INFO] |  +- org.opensaml:opensaml-saml-impl:jar:3.3.0:compile
[INFO] |  |  +- org.opensaml:opensaml-profile-api:jar:3.3.0:compile
[INFO] |  |  |  \- org.opensaml:opensaml-core:jar:3.3.0:compile
[INFO] |  |  |     \- io.dropwizard.metrics:metrics-core:jar:3.1.2:compile
[INFO] |  |  +- org.opensaml:opensaml-saml-api:jar:3.3.0:compile
[INFO] |  |  |  +- org.opensaml:opensaml-xmlsec-api:jar:3.3.0:compile
[INFO] |  |  |  \- org.opensaml:opensaml-soap-api:jar:3.3.0:compile
[INFO] |  |  +- org.opensaml:opensaml-security-impl:jar:3.3.0:compile
[INFO] |  |  |  \- org.opensaml:opensaml-security-api:jar:3.3.0:compile
[INFO] |  |  |     +- org.cryptacular:cryptacular:jar:1.1.1:compile
[INFO] |  |  |     \- org.bouncycastle:bcprov-jdk15on:jar:1.55:compile
[INFO] |  |  +- org.opensaml:opensaml-xmlsec-impl:jar:3.3.0:compile
[INFO] |  |  \- net.shibboleth.utilities:java-support:jar:7.3.0:compile
[INFO] |  |     +- com.google.guava:guava:jar:19.0:compile
[INFO] |  |     \- joda-time:joda-time:jar:2.7:compile
[INFO] |  +- org.opensaml:opensaml-xacml-impl:jar:3.3.0:compile
[INFO] |  |  \- org.opensaml:opensaml-xacml-api:jar:3.3.0:compile
[INFO] |  +- org.opensaml:opensaml-xacml-saml-impl:jar:3.3.0:compile
[INFO] |  |  \- org.opensaml:opensaml-xacml-saml-api:jar:3.3.0:compile
[INFO] |  +- org.jasypt:jasypt:jar:1.9.2:compile
[INFO] |  \- org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:jar:1.8.4:compile
[INFO] +- org.apache.wss4j:wss4j-ws-security-dom:jar:2.2.1:compile
[INFO] |  \- net.sf.ehcache:ehcache:jar:2.10.4:runtime
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.22:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] \- org.testng:testng:jar:6.11:test
[INFO]    +- com.beust:jcommander:jar:1.64:test
[INFO]    \- org.yaml:snakeyaml:jar:1.17:test

到目前为止,编译和运行正常.

Compiling and running works fine so far.

但是当我开始使用IntelliJ进行调试时,我得到了100多个错误的列表,例如:

But when I what to start debugging with IntelliJ, I get a list of over 100 errors like:

Error:java: the unnamed module reads package org.opensaml.saml.config from both opensaml.saml.api and opensaml.saml.impl
Error:java: the unnamed module reads package javax.xml.datatype from both xml.apis and java.xml
Error:java: the unnamed module reads package javax.xml.transform.dom from both xml.apis and java.xml
....

由于新的Java 9模块限制,这似乎是一个错误.但是如何处理呢?

This seems to be an error due to the new Java 9 module restrictions. But how to deal with here?

org.opensaml都是wss4j-ws-security-common 2.2.1的一部分(这是最新版本,于2018年1月发布). opensaml.saml.api和opensaml.saml.impl是3.3.0版,并且都使用相同版本的org.opensaml.saml.config.所以?

Both org.opensaml are part of wss4j-ws-security-common 2.2.1 (this is the last version, released in January 2018). opensaml.saml.api and opensaml.saml.impl are version 3.3.0 and both use org.opensaml.saml.config of the same version. So???

为什么"mvn编译"通过了,但是用IntelliJ调试却失败了?

And why does "mvn compile" pass, but debugging with IntelliJ fails?

推荐答案

我具有100%的" ERROR纬度":未命名的模块从xml.apis和java.xml读取包javax.xml "也在我的Java 9 IntelliJ项目中.

I had the same 100+ multititude of "ERROR: The unnamed module reads package javax.xml from both xml.apis and java.xml" in my Java 9 IntelliJ project too.

除了我每次尝试在IntelliJ中运行单元测试时都会得到它们.在命令行中使用maven进行构建和测试时,一切工作均正常进行;就像你一样.

Except I would get them whenever I tried to run unit tests in IntelliJ. Everything worked perfectly building and testing with maven from the command line; just like you.

我能够使我的错误消失……

I was able to make my errors go away by...

1 ),从多模块项目的顶级pom中删除以下内容...

1) Removing the following from the top-level pom of a multi-module project...

<dependency>
    <groupId>xml-apis</groupId>
    <artifactId>xml-apis</artifactId>
    <version>1.4.01</version>
</dependency>  
...
<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>${javaee.api.version}</version>
    <scope>provided</scope>
</dependency>

2 ),右键单击IntelliJ项目导航器中的顶级pom,然后选择" Maven-重新导入"

3 ),从IntelliJ菜单中执行" Build->构建模块[myModule] ".

只需弄清楚哪些Maven工件包含您的100多个" ERROR" 消息中列出的软件包.然后将其注释掉.重新导入.然后从菜单中选择"构建模块".无论如何,这对我有用.

Just work out which maven artifacts contain the packages listed in your 100+"ERROR" messages. Then comment them out. Reimport. Then "Build module" from the menu. That worked for me anyway.

我从pom删除的工件是从另一个用作模板的项目中推测性复制/粘贴到那里的.但幸运的是,我不需要任何一个.

The artifacts I removed from the pom were copy/pasted in there speculatively from another project I used as a template. But luckily I don't need any of them.

这篇关于java 9未命名模块在调试时(使用IntelliJ)从两者中读取软件包[X]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆