问题
So, it seems that I have a problem configuring proxy for SBT. I tried the following methods
Configured the following parameters in %SBT_HOME%\conf\stbconfig.txt:
-Dhttp.proxySet=true -Dhttp.proxyHost=proxy_server -Dhttp.proxyPort=proxy_port -Dhttp.nonProxyHosts="localhost|127.0.0.1" -Dhttp.proxyUser=username -Dhttp.proxyPassword=password -Dhttps.proxyHost=proxy_server -Dhttps.proxyPort=proxy_port -Dhttps.nonProxyHosts="localhost|127.0.0.1" -Dhttps.proxyUser=username -Dhttps.proxyPassword=password
I added the above parameters sbtopts file but didn't work.
I tried the solutions that said to pass the configurations in command line as environment variables ( JAVA_OPTS or SBT_OPTS) but it seems that it didn't worked for me.
I still got errors( Unresolved dependencies) and/or warnings ( [warn] Your proxy requires authentication.)
I use java 1.8.0_131 and sbt 1.0.2. Scala version is: 2.12.3.
The output of the sbt new scala/hello-world.g8 is:
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; sup
port was removed in 8.0
[info] Set current project to workspace (in build file:/D:/workspace/)
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scala-sbt.sbt-giter8-resolver#sbt-giter8-resolver_2.12;0.1.3: Res
olution failed several times for dependency: org.scala-sbt.sbt-giter8-resolver#s
bt-giter8-resolver_2.12;0.1.3 {compile=[default(compile)]}::
[warn] sbt-releases-repo: unable to get resource for org.scala-sbt.sbt-giter8-r
esolver#sbt-giter8-resolver_2.12;0.1.3: res=http://repo.typesafe.com/typesafe/iv
y-releases/org.scala-sbt.sbt-giter8-resolver/sbt-giter8-resolver_2.12/0.1.3/ivys
/ivy.xml: java.net.ConnectException: Failed to connect to repo.typesafe.com/34.2
06.225.108:80
[warn] sbt-plugins-repo: unable to get resource for org.scala-sbt.sbt-giter8-re
solver#sbt-giter8-resolver_2.12;0.1.3: res=http://repo.scala-sbt.org/scalasbt/sb
t-plugin-releases/org.scala-sbt.sbt-giter8-resolver/sbt-giter8-resolver_2.12/0.1
.3/ivys/ivy.xml: java.net.ConnectException: Failed to connect to repo.scala-sbt.
org/34.206.162.65:80
[warn] maven-central: unable to get resource for org/scala-sbt/sbt-giter8-resol
ver#sbt-giter8-resolver_2.12;0.1.3: res=http://repo1.maven.org/maven2/org/scala-
sbt/sbt-giter8-resolver/sbt-giter8-resolver_2.12/0.1.3/sbt-giter8-resolver_2.12-
0.1.3.pom: java.net.ConnectException: Failed to connect to repo1.maven.org/151.1
01.44.209:80
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] java.lang.RuntimeException: Retrieval of org.scala-sbt.sbt-giter8-resolv
er:sbt-giter8-resolver:0.1.3 failed.
[error] at scala.sys.package$.error(package.scala:27)
[error] at sbt.TemplateCommandUtil$.classpathForInfo(TemplateCommand.sca
la:119)
[error] at sbt.TemplateCommandUtil$.infoLoader(TemplateCommand.scala:81)
[error] at sbt.TemplateCommandUtil$.$anonfun$run$1(TemplateCommand.scala
:48)
[error] at sbt.TemplateCommandUtil$.$anonfun$run$1$adapted(TemplateComma
nd.scala:47)
[error] at scala.collection.LinearSeqOptimized.find(LinearSeqOptimized.s
cala:111)
[error] at scala.collection.LinearSeqOptimized.find$(LinearSeqOptimized.
scala:108)
[error] at scala.collection.immutable.List.find(List.scala:86)
[error] at sbt.TemplateCommandUtil$.run(TemplateCommand.scala:47)
[error] at sbt.TemplateCommandUtil$.runTemplate(TemplateCommand.scala:34
)
[error] at sbt.TemplateCommandUtil$.$anonfun$templateCommand$2(TemplateC
ommand.scala:17)
[error] at sbt.Command$.$anonfun$applyEffect$4(Command.scala:125)
[error] at sbt.Command$.$anonfun$applyEffect$2(Command.scala:121)
[error] at sbt.MainLoop$.processCommand(MainLoop.scala:121)
[error] at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:105)
[error] at sbt.State$$anon$1.runCmd$1(State.scala:227)
[error] at sbt.State$$anon$1.process(State.scala:233)
[error] at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:105)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.sc
ala:16)
[error] at sbt.MainLoop$.next(MainLoop.scala:105)
[error] at sbt.MainLoop$.run(MainLoop.scala:98)
[error] at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:76)
[error] at sbt.io.Using.apply(Using.scala:22)
[error] at sbt.MainLoop$.runWithNewLog(MainLoop.scala:70)
[error] at sbt.MainLoop$.runAndClearLast(MainLoop.scala:52)
[error] at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:37)
[error] at sbt.MainLoop$.runLogged(MainLoop.scala:29)
[error] at sbt.StandardMain$.runManaged(Main.scala:104)
[error] at sbt.xMain.run(Main.scala:71)
[error] at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error] at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error] at xsbt.boot.Launch$.run(Launch.scala:109)
[error] at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error] at xsbt.boot.Launch$.launch(Launch.scala:117)
[error] at xsbt.boot.Launch$.apply(Launch.scala:18)
[error] at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error] at xsbt.boot.Boot$.main(Boot.scala:17)
[error] at xsbt.boot.Boot.main(Boot.scala)
[error] Retrieval of org.scala-sbt.sbt-giter8-resolver:sbt-giter8-resolver:0.1.3
failed.
Note: Content of %USERPROFILE%.sbt\repositories is
[scala]
version: ${sbt.scala.version-auto}
[app]
org: ${sbt.organization-org.scala-sbt}
name: sbt
version: ${sbt.version-read(sbt.version)[0.13.5]}
class: ${sbt.main.class-sbt.xMain}
components: xsbti,extra
cross-versioned: ${sbt.cross.versioned-false}
[repositories]
local
sbt-releases-repo: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
sbt-plugins-repo: http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
maven-central: http://repo1.maven.org/maven2/
[boot]
directory: ${sbt.boot.directory-${sbt.global.base-${user.home}/.sbt}/boot/}
[ivy]
ivy-home: ${sbt.ivy.home-${user.home}/.ivy2/}
checksums: ${sbt.checksums-sha1,md5}
override-build-repos: ${sbt.override.build.repos-false}
repository-config: ${sbt.repository.config-${sbt.global.base-${user.home}/.sbt}/repositories}
回答1:
A workaround that I used was to setup an internal artifactory that proxies all the remote repositories.
来源:https://stackoverflow.com/questions/46582567/sbt-proxy-configuration-problems