Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java iText版本4.2.1在maven中央存储库中重定向_Java_Maven_Itext - Fatal编程技术网

Java iText版本4.2.1在maven中央存储库中重定向

Java iText版本4.2.1在maven中央存储库中重定向,java,maven,itext,Java,Maven,Itext,我们在一个项目中使用iText生成PDF报告,正是版本4.2.1,因为它是最后一个免费版本 <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>4.2.1</version> </dependency> com.lowagie 文字 4.2.1 今天早上,当我在一

我们在一个项目中使用iText生成PDF报告,正是版本4.2.1,因为它是最后一个免费版本

<dependency>
   <groupId>com.lowagie</groupId>
   <artifactId>itext</artifactId>
   <version>4.2.1</version>
</dependency>

com.lowagie
文字
4.2.1
今天早上,当我在一台新机器上克隆存储库时,我遇到了很多编译器错误,因为maven重定向到5.5.6版本,导入失败。在我们的研究中,我们发现上周maven central的pom文件发生了更改。从现在起,似乎不可能像以前那样添加jar依赖项


有人能告诉我,是否还有办法通过maven将iText集成到4.2.1版中

第一个解决方案

您可以在本地下载jar,然后使用以下命令在本地安装它

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> 
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
第二种解决方案:

您还可以在本地下载jar,并使用以下依赖项组引用它

<dependency>
    <groupId>com.lowagie</groupId>
    <artifactId>itext</artifactId>
    <version>4.2.1</version>
    <scope>system</scope>
    <systemPath>/PATHTOJAR/itext.jar</systemPath>
</dependency>

com.lowagie
文字
4.2.1
系统
/PATHTOJAR/itext.jar
如文件所述,发布iText forks 4.x.y版的人没有遵循以下原则:

我在foo.com上开发了一个补丁版本的foo项目,我应该使用哪个groupId?

修补/修改第三方项目时, 该修补版本将成为您的项目,因此应 在您控制的groupId下分发,就像您拥有的任何项目一样 已开发,从未在com.foo下开发。请参见上述有关的注意事项 groupId

他们使用groupId发布了一个非正式版本的iText,这让人们相信他们使用的是iText的原始版本,但事实并非如此。这一错误造成了许多混乱和挫折

为了避免混淆,iText Group重新获得了groupId,这样就没有第三方可以将侵犯第三方权利的软件甚至恶意软件引入您的代码库(当您允许Maven自动升级时,这是一种风险)

您声称iText 4.2.1是最后一个免费版本的说法是不正确的。iText 5之前的iText版本存在一些严重问题,但这是另一个讨论,也是2015年JavaOne会议上题为的主题

在任何情况下,最简单的解决方案是将依赖关系更改为:

<dependency>
  <groupId>com.lowagie</groupId>
  <artifactId>itext</artifactId>
  <version>[1.02b,2.1.7]</version>
  <scope>compile</scope>
</dependency>

com.lowagie

作为对的回答,我想了解更多的背景信息。

我在使用Gradle时也遇到了同样的问题

在我的build.gradle文件中的dependencies下

compile 'com.lowagie:itext:4.2.1'
将获取itextpdf-5.5.6.jar

运行命令

gradle myapp:dependencies
将显示如下所示的可传递依赖项:

\--- com.lowagie:itext:4.2.1
     \--- com.itextpdf:itextpdf:5.5.6

我的解决方案是将我拥有的原始itext-4.2.1.jar的副本上传到我们的Nexus存储库中,并给它一个不同的版本号。

我知道这是一个旧线程,但由于一些随机问题,我刚刚清除了我的.m2文件夹,不幸的是,然后得到了一个新的版本号“工件com.lowagie:itext:jar:4.2.1已重新定位到com.itextpdf:itextpdf:jar:5.5.6”

只是在试图回忆我们是如何修复的时候遇到了这个问题,所以我想我应该发布解决方案,我们必须阻止它尝试升级

转到%UserProfiles%\.m2\repository\com\lowagie\itext\4.2.1\

编辑itext-4.2.1.pom并从底部删除以下部分,这样就不会再次困扰您,您可以愉快地使用4.2.1:-

  <distributionManagement>
      <relocation>
          <groupId>com.itextpdf</groupId>
          <artifactId>itextpdf</artifactId>
          <version>5.5.6</version>
          <message>After release 2.1.7, iText moved from the MPLicense to the AGPLicense.
          The groupId changed from com.lowagie to com.itextpdf and the artifactId from itext to itextpdf.
          See http://itextpdf.com/functionalitycomparison for more information.</message>
      </relocation>
  </distributionManagement>

com.itextpdf
itextpdf
5.5.6
在2.1.7版之后,iText从MPLicense迁移到了AGPLlicense。
groupId从com.lowagie更改为com.itextpdf,artifactId从itext更改为itextpdf。
看见http://itextpdf.com/functionalitycomparison 了解更多信息。

谢谢你的评论。我知道这种可能性,但我希望找到一个更简单的解决方案…我添加了另一个解决方案。检查itAFAIK此路径必须是绝对的,不是吗?在这种情况下,我更喜欢第一个解决方案。也可以使用
${basedir}
像这样引用项目目录:
${basedir}/systemLib//itext.jar
如果您在project@DavideLorenzoMARINO第二种解决方案不是未来的证明,因为iText 4.2.1在Maven上发布的方式违反了在Maven上发布软件的规则(请参阅我的答案)。iText 4.2.1有可能会被移动到另一个groupId,并且您在回答中显示的依赖关系将不再有效。非常感谢您提供的背景信息@Bruno Lowagie,这对我帮助很大!抱歉,但诱使人们使用Affero版本并不好。重定向到2是否更有意义。1.7?
  <distributionManagement>
      <relocation>
          <groupId>com.itextpdf</groupId>
          <artifactId>itextpdf</artifactId>
          <version>5.5.6</version>
          <message>After release 2.1.7, iText moved from the MPLicense to the AGPLicense.
          The groupId changed from com.lowagie to com.itextpdf and the artifactId from itext to itextpdf.
          See http://itextpdf.com/functionalitycomparison for more information.</message>
      </relocation>
  </distributionManagement>