在我的项目中,我有一个使用多个 3rd 方库的包。让我们看一下依赖树:
[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 多个错误的列表,例如:
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 都是 wss4j-ws-security-common 2.2.1 的一部分(这是最后一个版本,于 2018 年 1 月发布)。opensaml.saml.api 和 opensaml.saml.impl 是 3.3.0 版本,并且都使用相同版本的 org.opensaml.saml.config。所以???
为什么“mvn compile”通过了,但是用 IntelliJ 调试却失败了?