解决Maven报错“Cannot resolve com.lowagie:itext:2.1.7.js7”

Maven下载2.1.7.js7版本的itext依赖时报错:“Cannot resolve com.lowagie:itext:2.1.7.js7”

问题原因:

由于在jasperreports的pom文件里指定了2.1.7.js7版本的itext依赖,而目前的Maven中央仓库或其他镜像仓库里是不存在这种带有js7等后缀版本。

目前itext已停止维护,并从4.2.2之后的版本开始从com.lowagie.itext迁移到com.itextpdf.itextpdf,有需要的话可以使用更高版本的itextpdf依赖。

解决方案:

排除jasperreports中的itext依赖并自行指定版本。

<dependency>
    <groupId>jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>6.10.0</version> <!--(or higher)-->
    <exclusions>
        <exclusion>
            <groupId>com.lowagie</groupId>
            <artifactId>itext</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itextpdf</artifactId>
    <version>5.5.13</version> <!--(or higher)-->
</dependency>


版权声明:本文为watson2017原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。