title: No qualifying bean of type 'java.util.Set<javax.persistence.EntityManager>
body: <p>After adding dependency of spring-boot-starter-data-jpa in my pom.xml file. I am getting this error.
  I searched and found <a href="https://stackoverflow.com/questions/42442823/sprint-boot-data-jpa-no-qualifying-bean-of-type-java-util-setjavax-persistenc">this</a>, it says that removing dependency of hibernate core will resolve this issue. However, the error still exist.</p>
  
  <p>Here is my stacktrace:</p>
  
  <pre><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jpaContext': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.util.Set&lt;javax.persistence.EntityManager&gt;' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
  at com.netpace.firebase.NetpaceFirebaseNotificationsApplication.main(NetpaceFirebaseNotificationsApplication.java:20) [classes/:na]
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.util.Set&lt;javax.persistence.EntityManager&gt;' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
  ... 19 common frames omitted
  </code></pre>
  
  <p>Here is my applicationContext.xml file :</p>
  
  <pre><code>&lt;bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
      destroy-method="close"&gt;
      &lt;property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" /&gt;
      &lt;property name="url"
          value="jdbc:sqlserver://localhost;databaseName=Firebase_Notification" /&gt;
      &lt;property name="username" value="sa" /&gt;
      &lt;property name="password" value="admin123" /&gt;
  
  &lt;/bean&gt;
  &lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="configLocation" value="classpath:hibernate.cfg.xml" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="transactionManager"
  class="org.springframework.orm.hibernate5.HibernateTransactionManager"&gt;
  &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>When I am autowiring sessionFactory in my Class it is throwing this exception. I don't know what I am doing wrong as, I am new to Java spring and configuring things in eclipse is really a mess.</p>
  
  <p>Here is my class where I am using sessionFactory:</p>
  
  <pre><code>@Component
  public class BaseClass&lt;T&gt; implements IBaseDAO&lt;T&gt; {
  
  @Autowired
  private SessionFactory sessionFactory;
  
  @Autowired
  private ErrorResponse error;
  
  @Override
  public Object save(T object) {
      // TODO Auto-generated method stub
      return this.getSession().save(object);
  }
  
  @Override
  public void remove(T object) {
      // TODO Auto-generated method stub
      this.getSession().delete(object);
  }
  
  @SuppressWarnings("unchecked")
  @Override
  public T update(T object) {
      // TODO Auto-generated method stub
      return (T) this.getSession().merge(object);
  }
  
  @SuppressWarnings("unchecked")
  @Override
  public T findById(long id, Class&lt;?&gt; persistClass) {
      // TODO Auto-generated method stub
      return (T) this.getSession().get(persistClass, id);
  }
  
  public SessionFactory getSessionFactory() {
      // sessionFactory = configuration.configure().buildSessionFactory();
      return sessionFactory;
  }
  
  public Session getSession() {
      SessionFactory session = getSessionFactory();
      return session.getCurrentSession();
  
  }
  
  @ExceptionHandler(RuntimeException.class)
  public ResponseEntity&lt;ErrorResponse&gt; handle(RuntimeException ex) {
      error.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
      error.setMessage(ex.getMessage());
      return new ResponseEntity&lt;ErrorResponse&gt;(error, HttpStatus.INTERNAL_SERVER_ERROR);
  
  }
  
  }
  </code></pre>