【问题标题】:How to properly specify jcenter repository in maven config?如何在 Maven 配置中正确指定 jcenter 存储库?
【发布时间】:2017-10-31 02:58:18
【问题描述】:

在 Gradle 中,我只需添加:

  repositories {  
   jcenter()  
  }

在 maven pom.xml 中执行相同操作的最简单和正确的方法是什么,或者我在哪里可以获得 jcenter 存储库的正确 url。

【问题讨论】:

标签: maven gradle artifactory bintray jcenter


【解决方案1】:

只需在您的 pom 中添加一个存储库部分:

<repositories>
    <repository>
        <id>jcenter</id>
        <name>jcenter</name>
        <url>https://jcenter.bintray.com</url>
    </repository>
</repositories>

【讨论】:

  • url 可以从仓库页面的右上角复制。例如,Spring releases repository 具有 https://dl.bintray.com/spring/jars maven 存储库 url
【解决方案2】:

您必须像下面这样定义 settings.xml。如果您在~/.m2/settings.xml 中定义它,它将对您的 maven 是全局的。如果将其定义为项目的资源,则可以将其与-s 参数绑定:

mvn -s settings.xml compile

<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd'
          xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
    
    <profiles>
        <profile>
            <repositories>
                <repository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray</name>
                    <url>https://jcenter.bintray.com</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray-plugins</name>
                    <url>https://jcenter.bintray.com</url>
                </pluginRepository>
            </pluginRepositories>
            <id>bintray</id>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>bintray</activeProfile>
    </activeProfiles>
</settings>

【讨论】:

  • 截至 2020 年 6 月,JCenter 仅可通过 HTTPS 使用。所以这里的url地址必须改成https。
【解决方案3】:

JFrog JCenter 的官方文档在: https://bintray.com/bintray/jcenter

点击设置!右上角的按钮。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-28
    • 2016-02-26
    • 2018-08-15
    • 1970-01-01
    • 1970-01-01
    • 2012-09-16
    相关资源
    最近更新 更多