簡體   English   中英

如何在 Maven 配置中正確指定 jcenter 存儲庫?

[英]How to properly specify jcenter repository in maven config?

在 Gradle 中,我只需添加:

  repositories {  
   jcenter()  
  }

在 maven pom.xml 中執行相同操作的最簡單和正確的方法是什么,或者我在哪里可以獲得 jcenter 存儲庫的正確 url。

您必須像下面這樣定義 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>

只需在你的 pom 中添加一個存儲庫部分:

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

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

點擊 SET ME UP! 右上角的按鈕。

陷害我!

可以使用這個settings.xml示例。
您可以以此為參考

暫無
暫無

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

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