【问题标题】:Allow to use http repository from repostories file允许使用存储库文件中的 http 存储库
【发布时间】:2020-01-15 08:58:30
【问题描述】:

我已更新到 SBT 1.3.0。现在我不断收到关于每个操作的警告:

[warn] insecure HTTP request is deprecated 'http://<company_domain>/nexus/content/repositories/mvnrepository/'; switch to HTTPS or opt-in as ("nexus" at "http://<company_domain>/nexus/content/repositories/mvnrepository/").withAllowInsecureProtocol(true)

我在 ~/.sbt/repositories 文件中尝试了以下选项:

nexus: ("http://<company_domain>/nexus/content/repositories/mvnrepository/").withAllowInsecureProtocol(true)

("nexus" at "http://<company_domain>/nexus/content/repositories/mvnrepository/").withAllowInsecureProtocol(true)

如何全局(针对所有已配置的存储库)允许 http 存储库?

【问题讨论】:

  • 此存储库是否支持 HTTPS?
  • 不,它只支持HTTP。

标签: sbt


【解决方案1】:

创建 ~/.sbt/resolvers.sbt 并添加到那里

resolvers += ("nexus" at "http://<company_domain>/nexus/content/repositories/mvnrepository/").withAllowInsecureProtocol(true)

resolvers ++= Seq(
  ("nexus" at "http://<company_domain>/nexus/content/repositories/mvnrepository/").withAllowInsecureProtocol(true),
  ("nexus" at "http://<company_domain>/nexus/content/repositories/mvnrepository/").withAllowInsecureProtocol(true),
...
)

【讨论】:

  • 您好,感谢您的回答!可悲的是,这对我不起作用:1. 当我离开 repositories 文件时 - 没有任何变化(警告仍然存在),2. 如果我将 repositories 文件设为空 - 我有很多依赖关系解析错误 3. 如果我删除了repositories 文件,只留下resolvers.sbt - Sbt 解决了一些依赖项(来自项目中添加的Maven 解析器),但在其他方面失败了 - 在我的情况下,似乎这个~/.sbt/resolvers.sbt 文件只是忽略了。任何想法为什么会发生?
【解决方案2】:

我也被困在这个问题上,但是在查看 SBT 源代码时,我发现如果您使用的是 1.3.11 之前的 SBT 启动器版本,它会自动将“allowInsecureProtocol”默认为 false,并且不会发出警告.见https://github.com/sbt/sbt/blob/7969a155b0978a925d3bd4aeefcb2ace163835db/main/src/main/scala/sbt/Defaults.scala#L4155

重要的是,这取决于启动器,即您实际安装的 SBT 版本。您的构建文件可能会引用支持此字段的更高版本,但如果启动器低于 1.13.11,您将看到此问题。您可以通过运行命令行检查您的版本:

sbt --version

解决方法是升级你已经安装的 SBT 版本。升级后,以下行在我的存储库文件中成功运行:

我的发布:http://artifactory.mydomain.net:8080/artifactory/sbt-release/,allowInsecureProtocol

【讨论】:

    【解决方案3】:

    在您的.sbt/repositories 文件中,您可以使用逗号添加设置:

    [repositories]
      nexus: http://<company_domain>/nexus/content/repositories/mvnrepository/, allowInsecureProtocol
    

    查看sbt documentation中的模式:

    name: url(, pattern)(,bootOnly)(,descriptorOptional)(,skipConsistencyCheck)(,allowInsecureProtocol)
    

    【讨论】:

      【解决方案4】:

      如果您使用 IDEA,我的回答可能会有所帮助。它发现在 sbt shell start IDEA 覆盖了从 1.3.12 到 1.5.5 的版本 我告诉 IDEA 不要覆盖我的项目 sbt 版本,然后允许 InsecureProtocol 与 Boris Azanov 建议的模式一起正确使用

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-09-12
        • 1970-01-01
        • 1970-01-01
        • 2012-03-07
        • 1970-01-01
        • 2015-05-08
        • 1970-01-01
        相关资源
        最近更新 更多