每次编译代码时,SBT 下载或解析 Jar

SBT Downloads or Resolves Jar each time when code is compiled

当我编译 sbt-scala 项目时,对于每次编译,sbt 都会下载或解析 jar,即使 jar 在 .ivy2 缓存中可用,并且组装需要很长时间。

当我使用 Maven 时,依赖项解析完成一次​​,如果存在于 .M2 中,组件将永远不会尝试下载相同的依赖项,并且所有项目将直接从 .M2 引用依赖项

当 jar 在 .ivy2 缓存中可用时,请告诉我有什么方法可以停止此解析或下载。

您可以将 sbt 设置为离线工作:

When offline := true, remote SNAPSHOTs will not be updated by a resolution, even an explicitly requested update. This should effectively support working without a connection to remote repositories. Reproducible examples demonstrating otherwise are appreciated. Obviously, update must have successfully run before going offline.

引自docs

如果可以跳过更新阶段。形成 sbt shell:

set skip in update := true

如果您只想使用缓存的工件,请添加到您的 build.sbt

updateOptions := updateOptions.value.withCachedResolution(true)

我个人的偏好是 override default repos 并添加我的本地 maven 存储库(这样可以解决问题但速度非常快)

有人已经 really far 解决了这个问题,建立了一个巨大的堆栈(有趣但不建议)