Sbt代理配置问题

时间:2017-10-05 09:46:49

标签: sbt http-proxy

因此,似乎我在为SBT配置代理时遇到问题。我尝试了以下方法

  1. 在%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
    
  2. 我添加了上面的参数sbtopts文件,但没有用。

  3. 我尝试了解决方案,这些解决方案在命令行中将配置作为环境变量(JAVA_OPTS或SBT_OPTS)传递,但似乎它对我没用。

  4. 我仍然遇到错误(未解决的依赖关系)和/或警告([警告]您的代理需要身份验证。)

    我使用java 1.8.0_131和sbt 1.0.2。 Scala版本是:2.12.3。

    sbt new scala / hello-world.g8 的输出是:

    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.
    

    注意:%USERPROFILE%.sbt \ repositories 的内容为

    [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 个答案:

答案 0 :(得分:0)

我使用的一种变通方法是设置一个内部工件,该内部工件代理所有远程存储库。