title: No adapter for handler with spring-boot custom starter
body: <p>I am developing a spring-boot custom starter, and I want my components/beans to be initialized only if some conditions are met. These beans include a REST controller. I have made a <code>@Configuration</code> class for that purpose:</p>
  
  <pre><code>@Configuration
  @ConditionalOnWebApplication
  @Conditional(MyConditions.class)
  public class MyConfiguration {
  
      @Bean
      public HandlerMapping registerController() {
          SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping();
  
          Map&lt;String, Object&gt; urlMap = new HashMap&lt;&gt;();
  
          urlMap.put("/custom", myController());
  
          handlerMapping.setUrlMap(urlMap);
  
          return handlerMapping;
      }
  
      @Bean
      public MyController myController() {
          return new MyController();
      }
  </code></pre>
  
  <p><code>MyController</code> class is:</p>
  
  <pre><code>public class MyController {
  
      @GetMapping
      public String hello() {
          return "I'm here";
      }
  }
  </code></pre>
  
  <p>What I am trying to achieve is that <code>localhost:8080/custom</code> answers <em>I'm here</em>, but instead of that what I get is:</p>
  
  <p><code>No adapter for handler [MyController@355b46cb]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler","path":"/custom"</code></p>
  
  <p>I don't want any of my beans to be initialized if conditions are not met, that is why <code>MyController</code> is not annotated with <code>@Controller</code> or <code>@RestController</code>.</p>
  
  <p>Any ideas on how I can achieve this?</p>
  
  <p><strong>Note</strong>: to test this, I have created a minimalistic SpringBoot project with a controller and I have added my custom starter as a dependency. <code>MyConfiguration</code> conditions are matched and beans are registered.</p>