簡體   English   中英

如何強制 Maven 使用 jcenter 存儲庫

[英]How to force Maven to use jcenter repoistory

我試圖獲得與 mvn 的依賴關系,但問題是其中一個包不在官方 repo 中。 我已經設法將 jcenter 添加到源中,但 maven 似乎不適合去那里看看。

在這里,它正在正確地查看下一個 repo

Downloading from central: https://repo.maven.apache.org/maven2/io/ktor/ktor-client-core/1.2.5/ktor-client-core-1.2.5.pom
Downloading from central: https://jcenter.bintray.com/io/ktor/ktor-client-core/1.2.5/ktor-client-core-1.2.5.pom

但這里不要:

Downloading from central: https://repo.maven.apache.org/maven2/io/ktor/ktor-http/1.2.5/ktor-http-1.2.5.pom
[WARNING] Missing POM for io.ktor:ktor-http:jar:1.2.5

mvn -Dartifact=io.ktor:ktor-client-core:1.2.5 -DremoteRepositories=central::default::https://jcenter.bintray.com/ dependency:get

io.ktor工件目前在 Maven Central 中對於高於 1.2.4 的版本不可用。 因此它們必須從Jcenter 存儲庫中下載。

ktor-http有一個ktor-utils 當調用ktor-http Maven 的依賴插件時,也會嘗試下載ktor-utils工件。 不幸的是,參數-DremoteRepositories=僅被考慮到工件ktor-http而不是依賴ktor-utils Maven 嘗試從 Maven 中央下載ktor-utils並失敗。

你可以通過調用來解決問題

mvn -Dartifact=io.ktor:ktor-utils:1.2.5 -DremoteRepositories=central::default::https://jcenter.bintray.com/  dependency:get

在下載ktor-http之前。 但是,這種方法需要大量手動下載步驟,我不建議這樣做。

更好的解決方案是Jcenter 存儲庫直接添加到您的 pom 中:

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

第三種選擇是將 Jcenter 存儲庫添加到您的settings.xml

暫無
暫無

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

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