[英]How can I migrate JCenter artifact to the Sonatype Maven repository?
[英]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>
可以使用這個settings.xml示例。
您可以以此為參考
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.