Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >java 9未命名模块从两个组件中读取包[X]。调试时(使用IntelliJ)

java 9未命名模块从两个组件中读取包[X]。调试时(使用IntelliJ)
EN

Stack Overflow用户
提问于 2018-03-23 00:47:51
回答 2查看 4.5K关注 0票数 4

在我的项目中,我有一个使用几个第三方库的包。让我们看一看依赖树:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
[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

到目前为止,编译和运行都很好。

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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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模块限制,这似乎是一个错误。但这里该怎么处理呢?

这两个org.opensaml都是wss4jws-安全-通用2.2.1的一部分(这是2018年1月发布的最后一个版本)。opensaml.saml.api和opensaml.saml.impl都是3.3.0版本,都使用相同版本的org.opensaml.saml.config。所以呢??

为什么"mvn编译“通过,但使用IntelliJ调试失败?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-03-26 13:39:23

在我的Java9 100+项目中,我也有"ERROR:未命名的模块从xml.apis和java.xml中读取包javax.xml“的多重特性。

但是,每当我试图在IntelliJ中运行单元测试时,我都会得到它们。与命令行的maven一起构建和测试一切都很完美;就像您一样。

我能让我的错误消失.

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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<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 - Reimport“。

( 3)在IntelliJ菜单中执行“构建->构建模块myModule”。

只需计算出哪些maven工件包含100+“错误”消息中列出的包。那就把它们评论掉。再进口。然后从菜单中“构建模块”。反正对我也有用。

我从pom中删除的工件是从我用作模板的另一个项目中推测地复制/粘贴到其中的。但幸运的是我一点也不需要。

票数 4
EN

Stack Overflow用户

发布于 2019-03-27 05:06:19

这是一个已知的想法错误。请投https://youtrack.jetbrains.com/issue/IDEA-171320

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49445583

复制
相关文章

相似问题

添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文