title: How to autowire spring-data CrudRepository
body: <p><strong><em>A bit of Details</em></strong>
  I am having some problem while running the code given below. I am getting the following exception. When i am trying the sample code of [CrudRepository for Spring Data][1]. </p>
  
  <p><strong>I have an Interface:</strong></p>
  
  <pre><code>package com.joydeep.springboot; 
  
  import org.springframework.data.repository.CrudRepository; 
  import com.joydeep.springboot.vo.Message; 
  
  public interface Test1 extends CrudRepository&lt;Message, String&gt; { }
  </code></pre>
  
  <p><strong>VO Class:</strong></p>
  
  <pre><code>package com.joydeep.springboot.vo;
  
  import java.util.Date;    
  import javax.persistence.Entity;
  import javax.persistence.Id;
  
  @Entity
  public class Message {
      @Id
      private String id;
      private String text;
      private String author;
      private Date created;
  
      public Message() {
          super();
      }
      public Message(String id, String text, String author, Date created) {
          super();
          this.id = id;
          this.text = text;
          this.author = author;
          this.created = created;
      }
      public String getId() {
          return id;
      }
      public void setId(String id) {
          this.id = id;
      }
      public String getText() {
          return text;
      }
      public void setText(String text) {
          this.text = text;
      }
      public String getAuthor() {
          return author;
      }
      public void setAuthor(String author) {
          this.author = author;
      }
      public Date getCreated() {
          return created;
      }
      public void setCreated(Date created) {
          this.created = created;
      }
      }
  </code></pre>
  
  <p><strong>Controller class:</strong></p>
  
  <pre><code>package com.joydeep.springboot; 
  import org.springframework.beans.factory.annotation.Autowired; 
  import org.springframework.web.bind.annotation.RequestMapping; 
  import org.springframework.web.bind.annotation.RestController;  
  
  @RestController 
  public class HelloCntrl { 
  
     @Autowired 
     Test1 test; 
  
     @RequestMapping("/hello")
     public String sayHi(){
        return "Hi"; 
     } 
  
  }
  </code></pre>
  
  <p><strong>Initializer class:</strong></p>
  
  <pre><code>package com.joydeep.springboot; 
  import org.springframework.boot.SpringApplication; 
  import org.springframework.boot.autoconfigure.SpringBootApplication; 
  
  @SpringBootApplication 
  public class CourseAPIStarter { 
     public static void main(String[] args) {
        SpringApplication.run(CourseAPIStarter.class); 
     } 
  }
  </code></pre>
  
  <p>pom.xml:</p>
  
  <p>
  
  <pre><code>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
  http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;io.springboot&lt;/groupId&gt;
      &lt;artifactId&gt;rest-course-api&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;Rest service course API&lt;/name&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.4.2.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&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;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.derby&lt;/groupId&gt;
              &lt;artifactId&gt;derby&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <blockquote>
    <p>Exception encountered during context initialization - cancelling refresh attempt: 
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'helloCntrl': Unsatisfied dependency expressed through field 'test'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.joydeep.springboot.Test1' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations {@org.springframework.beans.factory.annotation.Autowired(required=true)}</p>
  </blockquote>
  
  <p>The example i am referring is from this link.</p>
  
  <pre><code>https://spring.io/guides/gs/accessing-data-jpa/
  </code></pre>