简体   繁体   English

modular java project (IntelliJ IDEA): Module 'com.test' reads package 'javax.xml.bind' from both 'java.xml.bind' and 'java.xml.bind'

[英]modular java project (IntelliJ IDEA): Module 'com.test' reads package 'javax.xml.bind' from both 'java.xml.bind' and 'java.xml.bind'

I'm facing a really frustrating issue related to modules.我正面临一个与模块相关的非常令人沮丧的问题。 Can't figure out why I'm getting无法弄清楚为什么我会得到

Module 'com.test' reads package 'javax.xml.bind' from both 'java.xml.bind' and 'java.xml.bind'

How to solve it?如何解决?

Module list模块列表

module com.test {
    requires java.activation;
    requires slf4j.api;
    requires spring.context;
    requires java.persistence;
    requires spring.beans;
    requires org.apache.cxf.core;
    requires java.xml;
    requires java.xml.bind;
}

My environment我的环境

IntelliJ IDEA 2020.3.1 (Community Edition)

JAVA JDK 11

在此处输入图像描述

Update no.1更新 1 号

found a post on stackoverflow.com that has a very similar issue I'm facing Package 'com.example' reads package 'javafx.beans' from both 'javafx.base' and 'javafx.base'stackoverflow.com上找到了一个帖子,该帖子有一个非常相似的问题,我面临Package 'com.example' 读取 package 'xbase.

Update no.2更新 2

[INFO] +- org.hibernate:hibernate-core:jar:5.4.23.Final:provided
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.4.1.Final:provided
[INFO] |  +- javax.persistence:javax.persistence-api:jar:2.2:provided
[INFO] |  +- org.javassist:javassist:jar:3.24.0-GA:provided
[INFO] |  +- net.bytebuddy:byte-buddy:jar:1.10.17:provided
[INFO] |  +- antlr:antlr:jar:2.7.7:provided
[INFO] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.1.1.Final:provided
[INFO] |  +- org.jboss:jandex:jar:2.1.3.Final:provided
[INFO] |  +- com.fasterxml:classmate:jar:1.5.1:provided
[INFO] |  +- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] |  +- org.dom4j:dom4j:jar:2.1.3:provided
[INFO] |  +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.2.Final:provided
[INFO] |  +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] |  \- org.glassfish.jaxb:jaxb-runtime:jar:2.3.1:compile
[INFO] |     +- org.glassfish.jaxb:txw2:jar:2.3.1:compile
[INFO] |     \- com.sun.istack:istack-commons-runtime:jar:3.0.7:compile
[INFO] +- org.springframework:spring-context:jar:5.3.1:provided
[INFO] |  +- org.springframework:spring-aop:jar:5.3.1:provided
[INFO] |  +- org.springframework:spring-beans:jar:5.3.1:provided
[INFO] |  +- org.springframework:spring-core:jar:5.3.1:provided
[INFO] |  |  \- org.springframework:spring-jcl:jar:5.3.1:provided
[INFO] |  \- org.springframework:spring-expression:jar:5.3.1:provided
[INFO] +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] |  \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] +- org.apache.cxf:cxf-core:jar:3.4.1:compile
[INFO] |  +- com.fasterxml.woodstox:woodstox-core:jar:6.2.1:compile
[INFO] |  +- org.apache.ws.xmlschema:xmlschema-core:jar:2.2.5:compile
[INFO] |  +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] |  +- jakarta.jws:jakarta.jws-api:jar:2.1.0:compile
[INFO] |  +- jakarta.xml.soap:jakarta.xml.soap-api:jar:1.4.2:compile
[INFO] |  +- com.sun.activation:jakarta.activation:jar:1.2.2:compile
[INFO] |  +- com.sun.xml.messaging.saaj:saaj-impl:jar:1.5.2:runtime
[INFO] |  +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] |  \- org.jboss.spec.javax.rmi:jboss-rmi-api_1.0_spec:jar:1.0.6.Final:compile
[INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.3.3:runtime
[INFO] +- jakarta.xml.ws:jakarta.xml.ws-api:jar:2.3.3:compile
[INFO] +- com.sun.xml.ws:jaxws-rt:jar:2.3.3:compile
[INFO] |  +- com.sun.xml.ws:policy:jar:2.7.10:compile
[INFO] |  +- org.glassfish.ha:ha-api:jar:3.1.12:compile
[INFO] |  +- org.glassfish.external:management-api:jar:3.2.2:compile
[INFO] |  +- org.glassfish.gmbal:gmbal:jar:4.0.1:compile
[INFO] |  +- org.glassfish.pfl:pfl-tf:jar:4.1.0:compile
[INFO] |  +- org.glassfish.pfl:pfl-basic:jar:4.1.0:compile
[INFO] |  +- org.jvnet.staxex:stax-ex:jar:1.8.3:compile
[INFO] |  +- com.sun.xml.stream.buffer:streambuffer:jar:1.5.9:compile
[INFO] |  +- org.jvnet.mimepull:mimepull:jar:1.9.13:compile
[INFO] |  +- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.18:compile
[INFO] |  \- org.codehaus.woodstox:stax2-api:jar:4.1:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.13.3:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.13.3:compile
[INFO] +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.13.3:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.junit.jupiter:junit-jupiter-params:jar:5.7.0:test
[INFO] |  \- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.7.0:test
[INFO] |  +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] |  \- org.junit.platform:junit-platform-commons:jar:1.7.0:test
[INFO] \- org.mockito:mockito-junit-jupiter:jar:3.5.10:test
[INFO]    \- org.mockito:mockito-core:jar:3.5.10:test
[INFO]       +- net.bytebuddy:byte-buddy-agent:jar:1.10.13:test
[INFO]       \- org.objenesis:objenesis:jar:3.1:test

Thanks to Naman and the link provided in original post I found out that I was mixing jakarta.activation and javax.activation while using cxf .感谢 Naman 和原始帖子中提供的链接,我发现我在使用cxf时混合了jakarta.activationjavax.activation And, because cxf-xjc-plugin:3.3.1 generates code from xsd files using javax.activation I had to exclude everywhere in a pom jakarta.activation而且,因为cxf-xjc-plugin:3.3.1使用 javax.activation 从 xsd 文件生成代码,所以我不得不在 pom jakarta.activation中排除任何地方

Update No.1更新一号

to be precise I had to replace javax dependencies with jakarta dependencies that have javax package naming structure (ie javax.activation and not jakarta.activation ), ie准确地说,我必须用具有 javax package 命名结构(即javax.activation而不是jakarta.activation )的 jakarta 依赖项替换 javax 依赖项,即

<has javax packaging structure>
<dependency>
    <groupId>jakarta.jws</groupId>
    <artifactId>jakarta.jws-api</artifactId>
    <version>2.1.0</version>
</dependency>

but not但不是

<has jakarta packaging structure>
<dependency>
    <groupId>jakarta.jws</groupId>
    <artifactId>jakarta.jws-api</artifactId>
    <version>3.0.0</version>
</dependency>

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM