title: Spring Restful Service with Spring Boot - NoSuchBeanDefinitionException
body: <p>I am trying to build a Spring RESTful Webservice. I have ended up in NoSuchBeanDefinitionException. </p>
  
  <p>Could anyone please help me?
  Thanks in advance.</p>
  
  <p><b>Packages</b></p>
  
  <ul>
  <li>Entities - ch.example.entities.core</li>
  <li>repositories - ch.example.repositories</li>
  <li>service - ch.example.service</li>
  </ul>
  
  <p><b>ProfileRepository</b></p>
  
  <pre><code>@Repository
  public interface ProfileRepository extends JpaRepository&lt;AbstractProfile, Long&gt; {
  }
  </code></pre>
  
  <p><b>ProfileService</b></p>
  
  <pre><code>public interface ProfileService {
      List&lt;AbstractProfile&gt; findAll();
  }
  </code></pre>
  
  <p><b>ProfileServiceImpl</b>   </p>
  
  <pre><code> @Service
   public class ProfileServiceImpl implements ProfileService {  
  
      @Autowired
      private ProfileRepository repository;
  
      @Override
      public List&lt;AbstractProfile&gt; findAll() {
          return repository.findAll();
      }
   }
  </code></pre>
  
  <p><b>ProfileController</b></p>
  
  <pre><code>@RestController
  @ContextConfiguration(locations = "classpath:META-INF/mysql-spring-context.xml")
  public class ProfileController {
      @Autowired
      private ProfileService service;
  
      @RequestMapping("/profile")
      public List&lt;AbstractProfile&gt; getAllProfiles() {
          return service.findAll();
      }
  }
  </code></pre>
  
  <p><b>Spring ProfileApp</b></p>
  
  <pre><code>@Configuration
  @ComponentScan
  @EnableAutoConfiguration
  @EntityScan
  public class ProfileApp {
  
      public static void main(String[] args) {
          SpringApplication.run(ProfileApp.class, args);
      }
  }
  </code></pre>
  
  <p><b>Exception </b></p>
  
  <pre><code>Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [ch.example.repositories.ProfileRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  </code></pre>
  
  <p><b>Spring-Context</b></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jdbc="http://www.springframework.org/schema/jdbc"
      xmlns:jpa="http://www.springframework.org/schema/data/jpa"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
          http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository-1.7.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
      &lt;!-- Database --&gt;
      &lt;bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="url" value="jdbc:mysql://localhost:3306/entrevista_db" /&gt;
          &lt;property name="username" value="root" /&gt;
          &lt;property name="password" value="" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- Entity Manager --&gt;
      &lt;bean id="entityManagerFactory"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="persistenceUnitName" value="m-entrevista" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- Transaction Manager --&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- Jpa Rep --&gt;
      &lt;jpa:repositories base-package="ch.example.repositories"&gt;
      &lt;/jpa:repositories&gt; 
          &lt;context:annotation-config&gt;&lt;/context:annotation-config&gt;
      &lt;context:component-scan base-package="ch.example.service"/&gt;
  
  
      &lt;bean id="service" class="ch.example.service.ProfileServiceImpl"&gt;&lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>