Problems and analysis
One day I suddenly found that the project using Maven compiled to report the following error:
Failed to collect dependencies at :jasperreports:jar:6.10.0
-> :itext:jar:2.1.7.js7: Failed to read artifact descriptor for :itext:jar:2.1.7.js7:
Could not transfer artifact :itext:pom:2.1.7.js7
At first I thought the network was not good enough to connect to the remote library, or the remote library did not have the jar package, but later I found that it was not found in the Maven central repository.2.1.7.js7
Version ofitext
rely.
After searching on it, I found that many people encountered the same problem, all of which were because they used a certain version.jasperreports
, which eventually led to the error.
Since it is specified in the jasperreports pom file2.1.7.js7
Version ofitext
Dependency, but there is no such thing asjs7
etc. suffix version.
This version is a version where JasperReports has patched it to fix some bugs, but it is not released to the central library. However, these bugs have also been fixed in a higher version. You can use a higher version of itext to avoid these bugs.
Solution
Exclude the itext dependencies in jasperreports and specify the version by yourself.
- The pom is as follows:
<dependency> <groupId></groupId> <artifactId>jasperreports</artifactId> <version>6.10.0</version> <exclusions> <exclusion> <groupId></groupId> <artifactId>itext</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId></groupId> <artifactId>itext</artifactId> <version>2.1.7</version> </dependency>
The itext version here is specified according to its actual situation. Itext has been stopped and started from the version after 4.2.2.Migrate to
, if necessary, you can use a higher version of itextpdf dependency.
- The pom is as follows:
<dependency> <groupId>jasperreports</groupId> <artifactId>jasperreports</artifactId> <version>6.10.0</version> <!--(or higher)--> <exclusions> <exclusion> <groupId></groupId> <artifactId>itext</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId></groupId> <artifactId>itextpdf</artifactId> <version>5.5.13</version> <!--(or higher)--> </dependency>
Reference link:
- Dependency error in jasper-reports from itext
- IText, A Free Java PDF Library
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.