簡體   English   中英

iText 4.2.1 版在 maven 中央存儲庫中重定向

[英]iText version 4.2.1 redirected in maven central repository

我們在我們的一個項目中使用 iText 生成 PDF 報告,准確地說是 4.2.1 版,因為它是最后一個免費版本。

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

今天早上在一台新機器上克隆存儲庫時,我遇到了很多編譯器錯誤,因為 maven 重定向到版本 5.5.6 並且導入失敗。 在我們的研究中,我們發現 maven central 中的 pom 文件上周發生了變化。 從現在開始,似乎不可能像我們之前那樣添加 jar 依賴項了。

誰能告訴我,是否還有辦法通過 maven 在 4.2.1 版中集成 iText?

作為記錄在這里,誰發表了iText的叉版本4.xy人沒有按照規則由Apache的解釋

我有一個在 foo.com 上開發的 foo 項目的補丁版本,我應該使用什么 groupId?

當您修補/修改第三方項目時,該修補版本將成為您的項目,因此應在您控制的 groupId 下分發,就像您將開發的任何項目一樣,永遠不要在 com.foo 下。 請參閱上述有關 groupId 的注意事項。

他們使用groupId發布了 iText 的非官方版本,這讓人們相信他們使用的是 iText 的原始版本,但事實並非如此。 這個錯誤引起了很多混亂和沮喪。

為了避免混淆,iText Group 回收了groupId,這樣第三方就不能將侵犯第三方權利的軟件甚至惡意軟件引入您的代碼庫(這是您在允許 Maven 自動升級時承擔的風險)。

您關於 iText 4.2.1 是最后一個免費版本的指控是不正確的。 iText 5 之前的 iText 版本存在一些嚴重的問題,但這是 JavaOne 2015 上題為IANAL: What Developers Should Know About IP and Legal的另一個討論和會議演講的主題。

無論如何,最簡單的解決方案是將依賴項更改為:

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

請參閱this answer to Dependency error in jasper-reports from itext了解更多背景信息。

第一個解決方案

您可以在本地下載jar,然后使用以下命令將其安裝到本地。

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> 
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

使用您喜歡的 groupId、artifactId、版本和包裝。

在這種情況下:

mvn install:install-file -Dfile=itext.jar -DgroupId=com.lowagie
-DartifactId=itext -Dversion=4.2.1 -Dpackaging=jar

第二種解決方案:

也可以在本地下載jar,用下面的依賴組引用

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

我在使用 Gradle 時遇到了同樣的問題。

在我的 build.gradle 文件中,在依賴項下,

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 has been relocated to 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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM