title: Service bean not getting autowired in spring boot
body: <p>I'm creating a Spring boot application with one Controller, Service and Repository class.All these are defined below :</p>
  
  <p>MainClass</p>
  
  <pre><code>@SpringBootApplication
  public class MainClass  extends SpringBootServletInitializer {
  
      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
          return application.sources(MainClass.class);
      }
  
      public static void main(String[] args) {
          SpringApplication.run(MainClass.class, args);
      }
  
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>@RestController
  @EnableAutoConfiguration
  public class ExampleController {
  
      public static final Logger logger = LoggerFactory.getLogger(ExampleController.class);
  
      private CustomReportService customReportService;
  
      @Autowired
      public void setCustomReportService(CustomReportService customReportService){
          this.customReportService = customReportService;
      }
  
      @RequestMapping(value="/api/report/list", method= RequestMethod.GET)
      public ResponseEntity&lt;Collection&lt;CustomReport&gt;&gt; listAllCustomReports(){
          return new ResponseEntity&lt;&gt;((Collection&lt;CustomReport&gt;) customReportService.listAllCustomReports(), HttpStatus.OK);
      }
  }
  </code></pre>
  
  <p>Service Interface:</p>
  
  <pre><code>public interface CustomReportService {
      Iterable&lt;CustomReport&gt; listAllCustomReports();
  }
  </code></pre>
  
  <p>Service Impl :</p>
  
  <pre><code>@Service
  public class CustomReportServiceImpl implements CustomReportService{
  
      @Autowired
      private CustomReportRepository customReportRepository;
  
      @Autowired
      public void setCustomReportRepository(CustomReportRepository customReportRepository){
          this.customReportRepository = customReportRepository;
      }
  
      @Override
      public Iterable&lt;CustomReport&gt; listAllCustomReports() {
          return customReportRepository.findAll();
      }
  
  }
  </code></pre>
  
  <p>Repository :</p>
  
  <pre><code>public interface CustomReportRepository extends CrudRepository&lt;CustomReport, Long&gt; {
  }
  </code></pre>
  
  <p>On deployment, my app fails to start with the foll error : </p>
  
  <pre><code>2017-05-28 15:50:28.723 DEBUG 14708 --- [           main] o.s.b.d.LoggingFailure
  AnalysisReporter   : Application failed to start due to an exception
  
  org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.test.services.customreport.CustomReportService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1486) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:659) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
  
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) ~[spring-context-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
  </code></pre>
  
  <p>Please tell me where am i going wrong.</p>
  
  <p>Thanks!</p>