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

How to resolve dependency convergence error in jasperreports with commons-logging library?

环境:

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.2 并在 <dependencyManagement> 中添加一个条目。

只需排除其他依赖项,让它只针对其中一个依赖项。

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