簡體   English   中英

如何解決 Could not find artifact javax.xml.bind:jaxb-api:pom:2.3.0-b161121.1438 in central (https://repo1.maven.org/maven2)?

[英]How do I resolve Could not find artifact javax.xml.bind:jaxb-api:pom:2.3.0-b161121.1438 in central (https://repo1.maven.org/maven2)?

我正在遷移一個應用程序以使用 ehcache 3.10.0 但出現構建錯誤:無法在中央( https://repo1. maven.org/maven2

我在 local.m2 目錄中看到該文件:.m2\repository\javax\xml\bind\jaxb-api -- 2.3.0-b161121.1438

所以這是一個 IDE 問題,為什么在我的本地構建中看不到它,因為它確實存在於我的 local.m2 上,但是這個版本 (2.3.0-b161121.1438) 在maven、https://repo1 上仍然不可用。 maven.org/maven2/javax/xml/bind/jaxb-api/

因此構建因工件錯誤而失敗。 關於如何解決它的任何提示?

在 ehcache3 github 上報告了類似的問題: https://github.com/ehcache/ehcache3/issues/2881

這種依賴性導致了問題,來自 ehcache pom.xml: https://search.maven.org/artifact/org.ehcache/ehcache/3.10.0/jar

    <dependency>
      <groupId>org.glassfish.jaxb</groupId>
      <artifactId>jaxb-runtime</artifactId>
      <version>[2.2,3)</version>
      <scope>runtime</scope>
    </dependency>

由於開放式版本,以下依賴鏈導致此問題: Failed to collect dependencies at org.ehcache:ehcache:jar:3.10.0 -> org.glassfish.jaxb:jaxb-runtime:jar:2.3.0-b170127.1453 -> org.glassfish.jaxb:jaxb-core:jar:2.3.0-b170127.1453 -> javax.xml.bind:jaxb-api:jar:2.3.0-b161121.1438...

我能找到的唯一具有此特定版本的存儲庫是https://maven.java.net/#nexus-search;gav~javax.xml.bind~jaxb-api~2.3.0-b161121.1438~ ~

但是,如果您查看以下文件,您會看到從該存儲庫檢索工件時出現的錯誤: .m2\repository\javax\xml\bind\jaxb-api\2.3.0-b161121.1438\jaxb-api-2.3.0-b161121.1438.pom.lastUpdated

這是給我的(maven 3.8.4): https\://maven.java.net/content/repositories/releases/.error= http\://0.0.0.0/.error=Could not transfer artifact javax.xml.bind\:jaxb-api\:pom\:2.3.0-b161121.1438 from/to maven-default-http-blocker (http\://0.0.0.0/)\: Blocked mirror for repositories\: [...]

這是因為 maven 3.8.x 已默認開始阻止 HTTP 存儲庫。 您可以按如下方式取消阻止 HTTP 存儲庫: How to disable maven blocking external HTTP repositories?

但我建議您不要取消阻止不安全(非 HTTPS)存儲庫。 這需要在 maven settings.xml 中更改,使構建過程復雜化。

我的首選解決方案是向 pom.xml 文件添加一個排除項以忽略此特定jaxb-runtime版本。

        <dependency>
            <groupId>org.ehcache</groupId>
            <artifactId>ehcache</artifactId>
            <version>3.10.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.glassfish.jaxb</groupId>
                    <artifactId>jaxb-runtime</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

如果您仍然需要 jaxb-runtime 來編譯或運行您的項目,您可以通過在您自己的 pom.xml 中添加新的依賴項來包含任何其他兼容版本。 在這種情況下,您還可以使用依賴管理而不是排除。

你可以在這里選擇一個: https://search.maven.org/artifact/org.glassfish.jaxb/jaxb-runtime

確保它滿足 ehcache 要求: <version>[2.2,3)</version>

暫無
暫無

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

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