如何使用 commons-logging 库解决 jasperreports 中的依赖收敛错误?

Posted

技术标签:

【中文标题】如何使用 commons-logging 库解决 jasperreports 中的依赖收敛错误?【英文标题】:How to resolve dependency convergence error in jasperreports with commons-logging library? 【发布时间】:2021-02-10 20:28:31 【问题描述】:

环境:

JBoss7.2 Java 11

Maven 依赖:

...
<dependency>
   <groupId>net.sf.jasperreports</groupId>
   <artifactId>jasperreports</artifactId>
   <version>$jasperReport.version</version>
   <exclusions>
       <exclusion>
           <groupId>org.olap4j</groupId>
           <artifactId>olap4j</artifactId>
       </exclusion>
       <exclusion>
           <groupId>xml-apis</groupId>
           <artifactId>xml-apis</artifactId>
       </exclusion>
       <exclusion>
           <groupId>stax</groupId>
           <artifactId>stax-api</artifactId>
       </exclusion>
       <exclusion>
           <groupId>com.lowagie</groupId>
           <artifactId>itext</artifactId>
       </exclusion>
   </exclusions>
</dependency>
...

Dependency convergence error for commons-logging:commons-logging:1.2 paths to dependency are:
+-es.caib.accfor:accfor-commons:8.0.0
  +-net.sf.jasperreports:jasperreports:6.5.1
    +-commons-beanutils:commons-beanutils:1.9.4.redhat-00002
      +-commons-logging:commons-logging:1.2
and
+-es.caib.accfor:accfor-commons:8.0.0
  +-net.sf.jasperreports:jasperreports:6.5.1
    +-commons-digester:commons-digester:2.1
      +-commons-logging:commons-logging:1.1.1
and
+-es.caib.accfor:accfor-commons:8.0.0
  +-net.sf.jasperreports:jasperreports:6.5.1
    +-commons-logging:commons-logging:1.1.1
and
+-es.caib.accfor:accfor-commons:8.0.0
  +-net.sf.jasperreports:jasperreports:6.5.1
    +-org.codehaus.castor:castor-xml:1.3.3
      +-org.codehaus.castor:castor-core:1.3.3
        +-commons-logging:commons-logging:1.1.1
and
+-es.caib.accfor:accfor-commons:8.0.0
  +-net.sf.jasperreports:jasperreports:6.5.1
    +-org.codehaus.castor:castor-xml:1.3.3
      +-commons-logging:commons-logging:1.1.1

[WARNING] Rule 3: org.apache.maven.plugins.enforcer.DependencyConvergence failed with message:
Failed while enforcing releasability. See above detailed error message.

【问题讨论】:

【参考方案1】:

您需要选择其中一个版本,可能是1.2,然后在您的&lt;dependencyManagement&gt; 中添加一个条目。

【讨论】:

【参考方案2】:

只排除其他依赖项,只排除其中一个依赖项。

<exclusion>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
</exclusion>

【讨论】:

以上是关于如何使用 commons-logging 库解决 jasperreports 中的依赖收敛错误?的主要内容,如果未能解决你的问题,请参考以下文章

commons-logging,log4j,logback,slf4j之间的关系详解。

java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory解决方法

如何从 Gradle 中的所有依赖项中忽略特定的传递依赖项

java日志,(commons-loging log4j slf4j LogBack介绍)

commons-logging log4j的联系区别

Commons-logging(JCL)