Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup Spring Boot CLI behind a proxy

I am currently attempting to leverage the Spring Boot CLI behind my corporate proxy. I have tried a bunch of different ways of setting up the proxy for the Spring Boot CLI without success.

I have tried setting:

1) JAVA_OPTS environment variables for proxies

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

2) I have tried configuring just the http proxy environment variable

 http_proxy

I have previously found the github bug that was closed years ago, but it doesn't seem to be relevant: https://github.com/spring-projects/spring-boot/issues/136

Thanks for any help!

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>
like image 510
Matthew Fontana Avatar asked Nov 08 '16 21:11

Matthew Fontana


People also ask

What is spring boot proxy?

Proxies in Spring are an implementation of the Proxy design pattern and help facilitate the paradigm of Aspect-Oriented Programming. Benefits of Proxies ➕ Provide a surrogate to control access to an object.


1 Answers

Can you try maven proxy settings?? I got this issue resolved after setting correct proxy and the correct corporate repository.

https://maven.apache.org/guides/mini/guide-proxies.html
In settings.xml, you can use:

<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
In pom.xml in project, you can use:

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

Please let me know if it doesnt work for you..

like image 97
Anand Varkey Philips Avatar answered Sep 18 '22 08:09

Anand Varkey Philips