I tried to use Spring Boot using proxy.
I get the following message
$ spring init -l
Failed to retrieve help from service at 'https://start.spring.io'
(start.spring.io: unknown error)
I tried following
export http_proxy
export https_proxy
JAVA_OPTS settings
We are using commons HttpClient and we build a default instance via HttpClientBuilder
There are a bunch of system properties that are taken into account but I assume the following is the ones you're looking for:
http.proxyHost
http.proxyPort
Can you try that? If that does not work, please raise an issue on the boot tracker
Behind corporate proxy using locally installed cntlm proxy:
JAVA_OPTS
-Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128
Output:
$ spring init
Using service at https://start.spring.io
Content saved to 'demo.zip'
Use
-Dhttp.proxyHost=your.proxy.net -Dhttp.proxyPort=8080
Related
I am trying to integrate my application with the APM Framework. I've already done it for a series of other applications and everything worked accordingly. This specific Java SpringBoot application gives me the following error:
I've checked that the TLS certificate is valid in the container that the application is running. As I understand TLS 1.2 is used everywhere. I have checked and updated some http dependencies (okhttp) in case there was an issue with TLS there. No luck. I've checked that the APM SECRET TOKEN I am using is the correct one - and validated the APM environmental variables I've enetered.
I am calling ElasticApmAttacher.attach(); on the main of my Application class.
I have a elasticapm.properties file as follows:
enable_log_correlation=true
service_name=my-api-name
The following env vars:
ELASTIC_APM_APPLICATION_PACKAGES=my_classpath_here
ELASTIC_APM_SERVER_URL=apm_addresss_here
ELASTIC_APM_SECRET_TOKEN=token_here
Any ideas for what more to look for will be greatly appreciated.
I added the following env var:
ENV JAVA_OPTIONS=“-Dhttps.protocols=TLSv1.1,TLSv1.2”
Dockerfile base image change:
from java:8-jdk-alpine to openjdk:8u272-jdk
And it worked.
I am struggling to get spring cli running behind our corporate proxy. I read some suggestions in spring blogs on how to set the proxy and tried to follow, but w/o any success so far.
I tried the following
set http.proxyHost, http.proxyPort, http.proxyUser, http.proxyPassword as windows env variable
set corresponding variables for https as well
set JAVA_OPTS env. variable with -D...
verified that JAVA_OPTS variables are correctly picked up by setting debug on
Based on the above settings, the startup script is actually using the below command to run the spring cli
"C:\Program Files\Java\jdk1.8.0_66/bin/java.exe" -Dhttp.proxyHost=http://webproxy.company.com -Dhttp.proxyPort=8080 -Dhttps.proxyHost=https://webproxy.company.com -Dhttps.proxyPort=8080 -Dhttps.proxyUser=zencv -Dhttp.proxyPassword=dadada -cp "C:\My programs\spring-1.3.5.RELEASE\bin\\..\lib\*" org.springframework.boot.loader.JarLauncher init
I am always getting the same error
Using service at https://start.spring.io
Failed to retrieve metadata from service at 'https://start.spring.io' (Connect to start.spring.io:443 [start.spring.io/141.101.112.192, start.spring.io/190.93.243.191] failed: Connection refused: conn
ect)
In-order to verify that I can reach the site from a command line using the above proxy, I used curl with proxy and was successful. Please help!
I use spring boot 1.3.3.RELEASE at my ubuntu 15.10 and try to configure my app via env properties like this (guided by https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html):
> export SPRING_REDIS_HOST=somehost
> echo $SPRING_REDIS_HOST
somehost
My application.properties contains:
spring.redis.host=localhost
The problem is that I never get somehost in my app.
Any ideas? Did I miss something?
Thanks, George
The reason is that I set env in another terminal window so java process doesn't see it. Everything works fine now.
You must set the correct systemPropertiesMode
http://docs.spring.io/spring/docs/4.2.5.RELEASE/javadoc-api/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.html#setSystemPropertiesMode-int-
the default value is fallback.
"If not being able to resolve a placeholder with the specified properties, a system property will be tried."
How do I specify a http proxy to use when running a spring-boot fat war as a tomcat server?
I have tried the following which is not working.
java -jar my-application.war --http.proxyHost=localhost --http.proxyPort=3128 --https.proxyHost=localhost --https.proxyPort=3128
and
java -jar my-application.war -Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128
I've found that I need -Dhttps.proxySet=true in order for the proxy config to actually be used.
Put the JVM options before -jar. This should work:
java -Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 -jar my-application.war
Explanation
According to java command-line documentation, the command's syntax is:
java [ options ] -jar file.jar [ arguments ]
The arguments are the args that'll be received in your main(String[] args). So, it's totally your responsibility to use them somehow. And if you forward them to spring using SpringApplication.run(MyApplication.class, args);, then you need to find documentation that says how spring uses args in the run method.
The options, however, are not sent to your app. One of their uses is to set what java calls system properties using -Dproperty=value. According to Java Networking and Proxies, setting, e.g., http.proxyHost property makes the JVM proxy all your http request through that host.
You may configure all property of REMOTE DEVTOOLS (RemoteDevToolsProperties) in application.properties.
spring.devtools.remote.context-path= # Context path used to handle the remote connection.
spring.devtools.remote.proxy.host= # The host of the proxy to use to connect to the remote application.
spring.devtools.remote.proxy.port= # The port of the proxy to use to connect to the remote application.
spring.devtools.remote.restart.enabled=true # Whether to enable remote restart.
spring.devtools.remote.secret= # A shared secret required to establish a connection (required to enable remote support).
spring.devtools.remote.secret-header-name=X-AUTH-TOKEN # HTTP header used to transfer the shared secret.
need to add for authenticating proxy server
-Dhttp.proxyUser=**username**
-Dhttp.proxyPassword=**password**
I installed Spring boot CLI on Windows 7 but, I use a proxy. I would like to know how to configure proxy with Spring boot. I set the variable JAVA_OPTS with -Dhttp.proxyHost=proxyhostURL and
-Dhttp.proxyPort=proxyPortNumber but I have received the message :
"startup failed : General error during connection ..." after the command "spring run myscript.groovy".
I use jdk 1.7.0_51 and spring boot 1.0.0RC3.
Thanks in advance !
It looks like a known bug and there's a fix on github
Not sure if it's released yet tho...