title: No qualifying bean of type 'com.jpa.dao.UserRepository' available
body: <p>I am trying String JPA for the first time.</p>
  <p>I was following a Youtube video by Durgesh Sir.</p>
  <p>This is the error</p>
  <pre><code>Exception in thread &quot;main&quot; org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.jpa.dao.UserRepository' available
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:351)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:342)
      at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1177)
      at com.jpa.demo.BootjpaApplication.main(BootjpaApplication.java:13)
  
  </code></pre>
  <p>Following are my files</p>
  <p>BootjpaApplication.java (which contains main)</p>
  <pre><code>package com.jpa.demo;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.context.ApplicationContext;
  import com.jpa.dao.UserRepository;
  import com.jpa.entities.user;
  @SpringBootApplication
  public class BootjpaApplication {
  
      public static void main(String[] args) {
          ApplicationContext context= SpringApplication.run(BootjpaApplication.class, args);
          UserRepository userrepo= context.getBean(UserRepository.class);
          user user=new user();
          user.setName(&quot;Varun Dhawan&quot;);
          user.setCity(&quot;Paris&quot;);
          user.setStatus(&quot;happy&quot;);
          user user1= userrepo.save(user);
          System.out.println(user1);
      }
  </code></pre>
  <p>user.java (there are 4 variables. id is auto generated. Other 3 have getters and setters.</p>
  <pre><code>package com.jpa.entities;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  
  @Entity
  public class user {
      @Id
      @GeneratedValue(strategy =GenerationType.AUTO)
      private int id;
      
      private String name;
      private String city;
      private String status;
      public int getId() {
          return id;
      }
      public void setId(int id) {
          this.id = id;
      }
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public String getCity() {
          return city;
      }
      public void setCity(String city) {
          this.city = city;
      }
      public String getStatus() {
          return status;
      }
      public void setStatus(String status) {
          this.status = status;
      }
      public user(int id, String name, String city, String status) {
          super();
          this.id = id;
          this.name = name;
          this.city = city;
          this.status = status;
      }
      public user() {
          super();
          // TODO Auto-generated constructor stub
      }
      @Override
      public String toString() {
          return &quot;user [id=&quot; + id + &quot;, name=&quot; + name + &quot;, city=&quot; + city + &quot;, status=&quot; + status + &quot;]&quot;;
      }
      
  }
  </code></pre>
  <p>UserRepository.java</p>
  <pre><code>package com.jpa.dao;
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  
  import com.jpa.entities.user;
  @Repository
  public interface UserRepository extends JpaRepository&lt;user,Integer&gt; {
      
  }
  </code></pre>
  <p>Application.properties</p>
  <pre><code>spring.datasource.name=jpa
  spring.datasource.url=jdbc:mysql://localhost:3306/jpa
  spring.datasource.username=root
  spring.datasource.password=root@123
  spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
  
  spring.jpa.hibernate.ddl-auto=update
  </code></pre>
  <p>Thank you!</p>