title: Accessing CloudFoundry user-provided services using Spring Cloud connectors
body: <p>I'm trying to use Spring Cloud to consume a generic REST service from a Cloud Foundry app.</p>
  
  <p>This service is created using Spring Boot, as follows:</p>
  
  <pre><code>package com.something;
  
  @RestController
  public class DemoServiceController {
      @RequestMapping("/sayHi")
      public String sayHi() {
          return "Hello!";
      }
  }
  </code></pre>
  
  <p>This works fine - I can access <code>http://www.example.com/srv/demo/sayHi</code> and get "Hello!" back. </p>
  
  <p>Next, I created a user-provided service instance using the CF-CLI and bound it to my app. I can now see the bound service in <code>VCAP_SERVICES</code>.</p>
  
  <pre><code>cf cups my-demo-service -p '{"url":"http://www.example.com/srv/demo/"}'
  cf bs my-demo-app my-demo-service
  </code></pre>
  
  <p>Next, as described <a href="https://github.com/spring-cloud/spring-cloud-connectors/tree/master/spring-cloud-spring-service-connector#connecting-to-generic-services-1" rel="nofollow">here</a>, I added this bean to my app's Spring config, with the <code>connector-type</code> set to my original controller (I have a reference to it as well).</p>
  
  <pre><code>&lt;cloud:service id="myDemoService"
                 service-name="my-demo-service"
                 connector-type="com.something.DemoServiceController"
                 /&gt;
  </code></pre>
  
  <p>Now when I auto-wire <code>"myDemoService"</code> into my app,</p>
  
  <pre><code>@Autowired
  private DemoController myDemoService;
  </code></pre>
  
  <p>I get an error:</p>
  
  <blockquote>
    <p>No services of the specified type could be found.</p>
  </blockquote>
  
  <p>I've made sure to include all required dependencies, including <code>spring-cloud-spring-service-connector</code> and <code>spring-cloud-cloudfoundry-connector</code>.</p>
  
  <p>What's going wrong here? Am I giving the wrong bean parameters? Any help is much appreciated.</p>