如何在maven配置中正确指定jcenter存储库?

Igo*_*bak 8 artifactory gradle maven bintray jcenter

在Gradle中,我只需添加:

  repositories {  
   jcenter()  
  }
Run Code Online (Sandbox Code Playgroud)

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

小智 17

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

<repositories>
    <repository>
        <id>jcenter</id>
        <name>jcenter</name>
        <url>https://jcenter.bintray.com</url>
    </repository>
</repositories>
Run Code Online (Sandbox Code Playgroud)


Ser*_*era 14

您必须定义settings.xml,如下所示.如果你在〜/ .m2/settings.xml中定义它,那么你的maven将是全局的.如果将其定义为项目的资源,则可以将其与-s参数绑定:

mvn -s settings.xml编译

<?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>http://jcenter.bintray.com</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray-plugins</name>
                    <url>http://jcenter.bintray.com</url>
                </pluginRepository>
            </pluginRepositories>
            <id>bintray</id>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>bintray</activeProfile>
    </activeProfiles>
</settings>
Run Code Online (Sandbox Code Playgroud)


gal*_*ben 13

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

点击 SET ME UP!右上角的按钮。

陷害我!