如何在Maven配置中正确指定jcenter存储库? [英] How to properly specify jcenter repository in maven config?

查看:169
本文介绍了如何在Maven配置中正确指定jcenter存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Gradle中,我只需要添加:

In Gradle, I need simply add:

  repositories {  
   jcenter()  
  }

在maven pom.xml中执行相同操作的最简单,正确的方法是什么,或者在哪里可以找到jcenter存储库的正确URL.

What is the simplest and proper way to do the same in maven pom.xml or where can I get right url for jcenter repository.

推荐答案

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

You have to define settings.xml like the following. If you define it in ~/.m2/settings.xml it will be global to your maven. If you define it as a resource of your project you can bind it with the -s parameter:

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>

这篇关于如何在Maven配置中正确指定jcenter存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆