title: BUILD FAILURE with spring-retry on spring cloud services
body: <p>I have a set of services that use spring-cloud, connect to a config server, and register to a eureka server.</p>
  <p>I created a docker-compose.yml document in order to pull up all the containers in a simple way.</p>
  <p>so far so good</p>
  <p>There was a problem: the configuration server was not available when the other services were brought up.</p>
  <p>So I added <a href="https://docs.spring.io/spring-batch/docs/current/reference/html/retry.html#retry" rel="nofollow noreferrer">spring-retry</a> to make several retries. And it worked fine and i want to keep it.</p>
  <p>config:</p>
  <pre><code>spring.cloud.config.fail-fast=true
  spring.cloud.config.retry.initial-interval=4500
  spring.cloud.config.retry.max-attempts=12
  spring.cloud.config.retry.max-interval=9000
  spring.cloud.config.retry.multiplier=1.9
  </code></pre>
  <p>The problem now is that when building the .jar with &quot;mvn package&quot; the tests fail, since it retries to connect to the services and cannot find them:</p>
  <pre><code>Caused by: java.net.UnknownHostException: conf-server
          at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:229)
          at java.base/java.net.Socket.connect(Socket.java:609)
          at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:177)
          at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:508)
          at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:603)
          at java.base/sun.net.www.http.HttpClient.&lt;init&gt;(HttpClient.java:276)
          at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:375)
          at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:396)
          at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1253)
          at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
          at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
          at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:1015)
          at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:76)
          at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
          at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:66)
          at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:776)
          ... 102 common frames omitted
  
  [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 170.46 s &lt;&lt;&lt; FAILURE! - in com.px.labs.activityservice.ActivityServiceApplicationTests
  [ERROR] contextLoads  Time elapsed: 0.002 s  &lt;&lt;&lt; ERROR!
  java.lang.IllegalStateException: Failed to load ApplicationContext
  Caused by: org.springframework.cloud.config.client.ConfigClientFailFastException: Could not locate PropertySource and the fail fast property is set, failing
  Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for &quot;http://conf-server:8888/service-activities/default&quot;: conf-server; nested exception is java.net.UnknownHostException: conf-server
  Caused by: java.net.UnknownHostException: conf-server
  
  09:04:42,797 |-WARN in net.logstash.logback.appender.LogstashTcpSocketAppender[logstash] - Log destination logstash:5044: connection failed. java.net.UnknownHostException: logstash
          at java.net.UnknownHostException: logstash
          at      at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:229)
          at      at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
          at      at java.base/java.net.Socket.connect(Socket.java:609)
          at      at net.logstash.logback.appender.AbstractLogstashTcpSocketAppender$TcpSendingEventHandler.openSocket(AbstractLogstashTcpSocketAppender.java:762)
          at      at net.logstash.logback.appender.AbstractLogstashTcpSocketAppender$TcpSendingEventHandler.onStart(AbstractLogstashTcpSocketAppender.java:681)
          at      at net.logstash.logback.appender.AsyncDisruptorAppender$EventClearingEventHandler.onStart(AsyncDisruptorAppender.java:382)
          at      at net.logstash.logback.encoder.com.lmax.disruptor.BatchEventProcessor.notifyStart(BatchEventProcessor.java:224)
          at      at net.logstash.logback.encoder.com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:120)
          at      at java.base/java.lang.Thread.run(Thread.java:829)
  09:04:42,799 |-WARN in net.logstash.logback.appender.LogstashTcpSocketAppender[logstash] - Log destination logstash:5044: Waiting 29994ms before attempting reconnection.
  [INFO] 
  [INFO] Results:
  [INFO] 
  [ERROR] Errors: 
  [ERROR]   ActivityServiceApplicationTests.contextLoads » IllegalState Failed to load App...
  [INFO] 
  [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
  [INFO] 
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time:  03:27 min
  [INFO] Finished at: 2022-09-02T09:04:56-03:00
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project activity-service: There are test failures.
  </code></pre>
  <p>I tried to skip the tests with &quot;mvn package -Dmaven.test.skip&quot; and everything works fine. But I don't think it's a good practice.</p>
  <p>The question is:
  <strong>How can you use spring-retry and pass the tests?</strong></p>