繁体   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