我正在尝试在我的 Linux 虚拟机 (CentOS) 中安装 SBT,并且具有非常严格的安全性。
无法访问
- http://repo.typesafe.com/typesafe/ivy-releases/
- http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/
我已经提取了 SBT zip 文件并将 bin 路径添加到环境变量。
不出所料,我无法运行 SBT。
[admin@xxx]$ sbt
Getting org.scala-sbt sbt 0.13.12 ...
:: problems summary ::
:::: WARNINGS
module not found: org.scala-sbt#sbt;0.13.12
==== local: tried
/home/admin/.ivy2/local/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml
-- artifact org.scala-sbt#sbt;0.13.12!sbt.jar:
/home/admin/.ivy2/local/org.scala-sbt/sbt/0.13.12/jars/sbt.jar
==== Maven Central: tried
https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.pom
-- artifact org.scala-sbt#sbt;0.13.12!sbt.jar:
https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.jar
==== typesafe-ivy-releases: tried
https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml
==== sbt-ivy-snapshots: tried
https://repo.scala-sbt.org/scalasbt/ivy-snapshots/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: org.scala-sbt#sbt;0.13.12: not found
::::::::::::::::::::::::::::::::::::::::::::::
:::: ERRORS
Server access Error: Connection timed out url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.pom
Server access Error: Connection timed out url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.jar
Server access Error: Connection timed out url=https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml
Server access Error: Connection timed out url=https://repo.scala-sbt.org/scalasbt/ivy-snapshots/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml
:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.scala-sbt#sbt;0.13.12: not found
Error during sbt execution: Error retrieving required libraries
(see /home/admin/.sbt/boot/update.log for complete log)
Error: Could not retrieve sbt 0.13.12
我设法通过添加存储库文件让它使用我的存储库
存储库
[repositories]
local
my-maven-proxy-releases: http://nexuspro.company.com/nexus/service/local/repositories/
然后我用这个参数运行 SBT 命令:
sbt -Dsbt.repository.config=/sbt/conf/repositories
现在我的问题是 SBT 似乎使用与我的存储库不同的默认目录结构。
<my repository>/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.jar
所以我现在的问题是如何设置 SBT 来使用我的 jar?也许强制它使用我的 jar 的绝对路径
<my repository>/sbt-0.13.12.jar
最佳答案
这对那些没有互联网连接但需要使用 sbt 的人很有用。
这是基于 thirstycrow 的第三个选项。
首先,您需要在可以访问互联网的环境中更新您的 sbt。
sbt update
如果您需要特定版本的 sbt,您需要在调用 sbt 更新之前编辑您的 build.properties
然后将 .ivy2\cache 复制到目标环境(无互联网)
然后将缓存设置为存储库
存储库
[repositories]
local
cache: file://home/admin/.ivy2/cache, [organisation]/[module]/[type]s/[module]-[revision].[type], [organisation]/[module]/ivy-[revision].xml
然后调用sbt,参数指向你的版本库文件
sbt -Dsbt.repository.config=/sbt/conf/repositories
关于linux - 如何让 sbt 使用我本地存储库中的 jar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43250912/