当前位置: 首页 > 知识库问答 >
问题:

如何在代理背后设置Spring Boot CLI

公孙涵育
2023-03-14

我目前正在尝试利用Spring Boot CLI支持我的公司代理。我尝试了一系列不同的方法来设置Spring Boot CLI的代理,但都没有成功。

我已尝试设置:

-Dhttp.proxyHost=proxyhostURL
-Dhttp.proxyPort=proxyPortNumber
-Dhttp.proxyUser=someUserName
-Dhttp.proxyPassword=somePassword
 http_proxy

我以前发现过几年前关闭的github bug,但似乎与此无关:https://github.com/spring-projects/spring-boot/issues/136

谢谢你的帮助!

C:\Windows\system32>spring cloud eureka
Resolving dependencies..

███████╗██████╗ ██████╗ ██╗███╗   ██╗ ██████╗      ██████╗██╗      ██████╗ ██╗   ██╗██████╗
██╔════╝██╔══██╗██╔══██╗██║████╗  ██║██╔════╝     ██╔════╝██║     ██╔═══██╗██║   ██║██╔══██╗
███████╗██████╔╝██████╔╝██║██╔██╗ ██║██║  ███╗    ██║     ██║     ██║   ██║██║   ██║██║  ██║
╚════██║██╔═══╝ ██╔══██╗██║██║╚██╗██║██║   ██║    ██║     ██║     ██║   ██║██║   ██║██║  ██║
███████║██║     ██║  ██║██║██║ ╚████║╚██████╔╝    ╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝
╚══════╝╚═╝     ╚═╝  ╚═╝╚═╝╚═╝  ╚═══╝ ╚═════╝      ╚═════╝╚══════╝ ╚═════╝  ╚═════╝ ╚═════╝

-- Spring Cloud Launcher --

2016-11-22 07:21:24.970  INFO 12076 --- [-cloud-launcher] o.s.boot.SpringApplication               : Starting application on WKSP0006B796 with PID 12076 (D:\UPSData\DevRepo\spring-boot-cli-1.4.1.RELEASE-bin\spring-1.4.1.RELEASE\lib\spring-boot-cli-1.4.1.RELEASE.jar started by GSD4TYK in C:\Windows\system32)
2016-11-22 07:21:24.998  INFO 12076 --- [-cloud-launcher] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
2016-11-22 07:21:26.097  INFO 12076 --- [-cloud-launcher] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@34f39db4: startup date [Tue Nov 22 07:21:26 EST 2016]; root of context hierarchy
2016-11-22 07:21:28.503  INFO 12076 --- [-cloud-launcher] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-11-22 07:21:30.727  INFO 12076 --- [-cloud-launcher] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-11-22 07:21:30.792  INFO 12076 --- [-cloud-launcher] o.s.boot.SpringApplication               : Started application in 9.955 seconds (JVM running for 17.554)
Exception in thread "spring-cloud-launcher" java.lang.IllegalStateException: failed to resolve MavenResource: org.springframework.cloud.launcher:spring-cloud-launcher-eureka:jar:1.2.1.RELEASE
        at org.springframework.cloud.deployer.resource.maven.MavenArtifactResolver.resolve(MavenArtifactResolver.java:276)
        at org.springframework.cloud.deployer.resource.maven.MavenResource.getFile(MavenResource.java:169)
        at org.springframework.cloud.deployer.spi.local.AbstractLocalDeployerSupport.buildExecutionCommand(AbstractLocalDeployerSupport.java:96)
        at org.springframework.cloud.deployer.spi.local.AbstractLocalDeployerSupport.buildProcessBuilder(AbstractLocalDeployerSupport.java:141)
        at org.springframework.cloud.deployer.spi.local.LocalAppDeployer.deploy(LocalAppDeployer.java:122)
        at org.springframework.cloud.launcher.deployer.Deployer.deployInternal(Deployer.java:199)
        at org.springframework.cloud.launcher.deployer.Deployer.deploy(Deployer.java:105)
        at org.springframework.cloud.launcher.deployer.DeployerThread.launch(DeployerThread.java:116)
        at org.springframework.cloud.launcher.deployer.DeployerThread.run(DeployerThread.java:61)
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.springframework.cloud.launcher:spring-cloud-launcher-eureka:jar:1.2.1.RELEASE from/to central (http://repo1.maven.org/maven2): Connect to repo1.maven.org:80 timed out
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifacts(DefaultRepositorySystem.java:302)
        at org.springframework.cloud.deployer.resource.maven.MavenArtifactResolver.resolve(MavenArtifactResolver.java:273)
        ... 8 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.springframework.cloud.launcher:spring-cloud-launcher-eureka:jar:1.2.1.RELEASE from/to central (http://repo1.maven.org/maven2): Connect to repo1.maven.org:80 timed out
        at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:43)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
        at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
        ... 11 more
Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to repo1.maven.org:80 timed out
        at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:122)
        at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:179)
        at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:328)
        at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:612)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:447)
        at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:884)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
        at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:164)
        at org.eclipse.aether.transport.http.HttpTransporter.execute(HttpTransporter.java:287)
        at org.eclipse.aether.transport.http.HttpTransporter.implGet(HttpTransporter.java:243)
        at org.eclipse.aether.spi.connector.transport.AbstractTransporter.get(AbstractTransporter.java:59)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:447)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:350)
        ... 16 more
2016-11-22 07:22:02.575  INFO 12076 --- [       Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@34f39db4: startup date [Tue Nov 22 07:21:26 EST 2016]; root of context hierarchy
2016-11-22 07:22:02.591  INFO 12076 --- [       Thread-1] o.s.cloud.launcher.deployer.Deployer     :

Shutting down ...

2016-11-22 07:22:02.591  INFO 12076 --- [       Thread-1] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
C:\Windows\system32>

共有1个答案

施念
2023-03-14

你能试试maven代理设置吗??在设置正确的代理和正确的公司存储库后,我解决了这个问题。

https://maven.apache.org/guides/mini/guide-proxies.html
在settings.xml中,您可以使用:

<settings>
  .
  .
  <proxies>
   <proxy>
      <id>example-proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.example.com</host>
      <port>8080</port>
      <username>proxyuser</username>
      <password>somepassword</password>
      <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
    </proxy>
  </proxies>
  .
  .
</settings>

https://maven.apache.org/guides/introduction/introduction-to-repositories.html
在project中的pom.xml中,可以使用:

<project>
  ...
  <repositories>
    <repository>
      <id>my-internal-site</id>
      <url>http://myserver/repo</url>
    </repository>
  </repositories>
  ...
</project>

如果对你不起作用,请告诉我。

 类似资料:
  • 问题内容: 我可以如下设置Firefox的代理设置。 但是我也需要设置Chrome。.有人可以帮助我怎么做吗? 谢谢拉吉 问题答案: 您可以尝试使用该类,如下所示:

  • 我有一个WordPress博客运行在反向代理(Apache)后面。 httpd。维奥斯特。形态: 博客工作正常,我可以以管理员身份登录,但当尝试保存设置或删除插件(出现wp_重定向)时,我会被重定向到登录页面,因为wordpress显然没有找到/接受会话cookie,并且操作没有完成。 因此,我增加了这一行: (请参阅Apache代理cookies仅适用于第一个应用程序) 这似乎解决了问题。然而,

  • 问题内容: 我正在尝试运行安装pip的脚本:get-pip.py,并且由于我的网络位于HTTP代理后面而导致连接超时。有什么方法可以在Python 2.7安装中配置HTTP代理以安装我要安装的内容? 注意:我正在使用Windows。以下是我遇到的错误: 问题答案: 似乎已更新为使用环境变量和。 视窗: Linux / OS X: 但是,如果这仍然无法解决问题,您始终可以通过设置相同的环境变量,使用

  • 我有一个奇怪的小问题:如何设置截击中的用户代理? 我需要一些网站的完整版本(桌面版),而不是手机版。 我试图将变量userAgent从“volley/0”改为“Mozilla/5.0(X11;Linux i686)AppleWebKit/537.36(KHTML,比如Gecko)Chrome/27.0.1453.93 Safari/537.36”(我的Chrome)。没什么区别。 有什么建议吗?

  • 我正在尝试运行一个安装pip:get-pip.py的脚本,并且由于我的网络位于HTTP代理后面而导致连接超时。是否有某种方法可以在我的Python 2.7安装中配置HTTP代理以安装我正在尝试安装的内容? 注意:我正在使用Windows。下面是我遇到的错误:

  • 问题内容: 我有支持Hateoas的Spring Data Rest。它在代理后面。 后端网址: 代理网址: 当我查询代理url时,例如,我得到一个href带有domain链接的响应。我需要域名。 问题答案: 从Spring-Boot 2.1 / Spring 5.1开始,Spring将处理X-Forwarded- *的职责从Spring HATEOAS转移到Spring MVC。 现在,你需要注