title: Field restTemplate required a single bean, but 2 were found
body: <p>I am trying to resolve an issue with this code:</p>
  
  <pre><code>import io.christdoes.wealth.tracker.controller.error.ReCaptchaInvalidException;
  import io.christdoes.wealth.tracker.controller.error.ReCaptchaUnavailableException;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  import org.springframework.util.StringUtils;
  import org.springframework.web.client.RestClientException;
  import org.springframework.web.client.RestOperations;
  import org.springframework.web.client.RestTemplate;
  
  import javax.servlet.http.HttpServletRequest;
  import java.net.URI;
  import java.util.regex.Pattern;
  
  @Service("captchaService")
  public class CaptchaService implements ICaptchaService {
      private final static Logger LOGGER = LoggerFactory.getLogger(CaptchaService.class);
  
      @Autowired
      private HttpServletRequest request;
  
      @Autowired
      private CaptchaSettings captchaSettings;
  
      @Autowired
      private ReCaptchaAttemptService reCaptchaAttemptService;
  
      @Autowired
      private RestOperations restTemplate;
  
      private static final Pattern RESPONSE_PATTERN = Pattern.compile("[A-Za-z0-9_-]+");
  
      @Override
      public void processResponse(final String response) {
          LOGGER.debug("Attempting to validate response {}", response);
  
          if (reCaptchaAttemptService.isBlocked(getClientIP())) {
              throw new ReCaptchaInvalidException("Client exceeded maximum number of failed attempts");
          }
  
          if (!responseSanityCheck(response)) {
              throw new ReCaptchaInvalidException("Response contains invalid characters");
          }
  
          final URI verifyUri = URI.create(String.format("https://www.google.com/recaptcha/api/siteverify?secret=%s&amp;response=%s&amp;remoteip=%s", getReCaptchaSecret(), response, getClientIP()));
          try {
              final GoogleResponse googleResponse = restTemplate.getForObject(verifyUri, GoogleResponse.class);
              LOGGER.debug("Google's response: {} ", googleResponse.toString());
  
              if (!googleResponse.isSuccess()) {
                  if (googleResponse.hasClientError()) {
                      reCaptchaAttemptService.reCaptchaFailed(getClientIP());
                  }
                  throw new ReCaptchaInvalidException("reCaptcha was not successfully validated");
              }
          } catch (RestClientException rce) {
              throw new ReCaptchaUnavailableException("Registration unavailable at this time.  Please try again later.", rce);
          }
          reCaptchaAttemptService.reCaptchaSucceeded(getClientIP());
      }
  
      private boolean responseSanityCheck(final String response) {
          return StringUtils.hasLength(response) &amp;&amp; RESPONSE_PATTERN.matcher(response).matches();
      }
  
      @Override
      public String getReCaptchaSite() {
          return captchaSettings.getSite();
      }
  
      @Override
      public String getReCaptchaSecret() {
          return captchaSettings.getSecret();
      }
  
      private String getClientIP() {
          final String xfHeader = request.getHeader("X-Forwarded-For");
          if (xfHeader == null) {
              return request.getRemoteAddr();
          }
          return xfHeader.split(",")[0];
      }
  }
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>web - 2019-09-25 14:20:18,416 [restartedMain] INFO  o.a.c.c.StandardService - Stopping service [Tomcat]
  web - 2019-09-25 14:20:18,491 [restartedMain] ERROR o.s.b.d.LoggingFailureAnalysisReporter - 
  
  ***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  Field restTemplate in io.christdoes.wealth.tracker.captcha.CaptchaService required a single bean, but 2 were found:
      - org.springframework.hateoas.config.ConverterRegisteringWebMvcConfigurer#0: defined in null
      - org.springframework.hateoas.config.ConverterRegisteringWebMvcConfigurer#1: defined in null
  
  
  Action:
  
  Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
  
  
  Process finished with exit code 0
  </code></pre>
  
  <p>I have been trying to resolve this issue and could not find a way to resolve it. I kept on getting the above error. </p>
  
  <p>I have searched both SO and Github where similar errors were reported but non helped. Someone noted that it's a dependency issue, that's having both spring-web, and hateoas could be the issue. I removed the web yet the problem persists.</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-hateoas&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Though an earlier project with spring-boot dependencies of version <code>2.0.4</code> worked, I am presently using the latest version which is <code>2.1.8</code>. I will not like to revert to the earlier version because I have recent codes that I solely used <code>2.1.8</code>.</p>
  
  <p>What am I to do to get past this challenge?</p>