在 sbt 中通过 https 访问 maven repo

Access maven repo over https in sbt(在 sbt 中通过 https 访问 maven repo)

本文介绍了在 sbt 中通过 https 访问 maven repo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 sbt(scala) 构建的 java 项目.直到昨天这还有效,但今天我发现从 maven 中提取 repo 时出现问题

I have a java project which uses sbt(scala) for build. Up until yesterday this was working, but today I am seeing an issue in pulling a repo from maven

esolving org.codehaus.plexus#plexus-component-api;1.0-alpha-16 ...

[error] SERVER ERROR: HTTPS Required url=http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-component-api/1.0-alpha-16/plexus-component-api-1.0-alpha-16.pom

[warn]  module not found: org.codehaus.plexus#plexus-component-api;1.0-alpha-16

[warn] ==== typesafe-ivy-releases: tried

[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.codehaus.plexus/plexus-component-api/1.0-alpha-16/ivys/ivy.xml

[warn] ==== sbt-plugin-releases: tried

[warn]   http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.codehaus.plexus/plexus-component-api/1.0-alpha-16/ivys/ivy.xml

[warn] ==== local: tried

[warn]   /root/.ivy2/local/org.codehaus.plexus/plexus-component-api/1.0-alpha-16/ivys/ivy.xml

[warn] ==== activator-local: tried

[warn]   file:/heimdall/app/projects/load-test/content-engine/repository/org.codehaus.plexus/plexus-component-api/1.0-alpha-16/ivys/ivy.xml

[warn] ==== public: tried

[warn]   http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-component-api/1.0-alpha-16/plexus-component-api-1.0-alpha-16.pom

[warn] ==== typesafe-releases: tried

[warn]   http://repo.typesafe.com/typesafe/releases/org/codehaus/plexus/plexus-component-api/1.0-alpha-16/plexus-component-api-1.0-alpha-16.pom

[warn] ==== typesafe-ivy-releasez: tried

[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.codehaus.plexus/plexus-component-api/1.0-alpha-16/ivys/ivy.xml

[warn] ==== Typesafe repository: tried

[warn]   http://repo.typesafe.com/typesafe/releases/org/codehaus/plexus/plexus-component-api/1.0-alpha-16/plexus-component-api-1.0-alpha-16.pom

根据我的推断,repo 似乎已移至 https 端点.并且 pom 文件在 https 端点上可用.问题是这不是我项目中的直接依赖项,而是通过其他一些依赖项传递而来.对于这种特定的依赖,我该如何使用 https?

Based on what I could infer, the repo seems to have been moved to https endpoint. And pom file is available on https endpoint. The issue is that this is not a direct dependency in my project but coming transitively via some other dependency. How do I use https for this specific dependency?

我使用的是 sbt 版本 0.13.5.我检查了 参考手册 并添加了 DefaultMavenRepository 在 build.sbt 中明确

I am using sbt version 0.13.5. I checked the reference manual for it, and added DefaultMavenRepository explicitly in build.sbt

resolvers += DefaultMavenRepository

根据这个官方文档,DefaultMavenRepository 指向安全端点.在此之前,我在 build.sbt 中尝试过以下操作

As per this official documentation, the DefaultMavenRepository points to secure endpoint. Before this, I had tried the following in build.sbt

resolvers += "Maven Repo" at  "https://repo1.maven.org/maven2/" 

并添加了

"org.codehaus.plexus" % "plexus-component-api" % "1.0-alpha-16", 

在我的 build.sbt 中明确地作为 libraryDepdency 以便它可以被缓存并且不会传递到我可能无法控制它从哪里拉出的地方.但这也失败了.我清除了 m2 和 ivy2 缓存

as libraryDepdency explicitly in my build.sbt so that it can be cached and not come transitively where I may not have control over where it would be pulled from. But this also fails. I cleared both m2 and ivy2 caches

推荐答案

正如 Sarvesh 所说,问题是我使用的是 sbt 版本 0.13.5.DefaultMavenRepository 从 v0.13.6 开始指向 https 端点(文档没有提到这一点).升级版本后,我能够拉取所有依赖项.

As mentioned by Sarvesh, the issue was that I was using sbt version 0.13.5. And DefaultMavenRepository started pointing to https endpoint from v0.13.6(the documentation does not mention this). After bumping up the version, I was able to pull all dependencies.

这篇关于在 sbt 中通过 https 访问 maven repo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 sbt 中通过 https 访问 maven repo

基础教程推荐