title: No matching PlatformTransactionManager bean found for qualifier 'transactionManager'
body: <p>I am new to spring world. I have been trying to write a basic application using spring data, JPA using Hibernate and MYSql Database.
  I am seeing the error:</p>
  
  <blockquote>
    <p>No matching PlatformTransactionManager bean found for qualifier
    'transactionManager'</p>
  </blockquote>
  
  <p>Here is my spring-config.xml:</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:jpa="http://www.springframework.org/schema/data/jpa" 
      xmlns:context="http://www.springframework.org/schema/context" 
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context.xsd
      http://www.springframework.org/schema/tx
      http://www.springframework.org/schema/tx/spring-tx.xsd
      http://www.springframework.org/schema/data/jpa
      http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"&gt;
  
      &lt;jpa:repositories base-package="com.levadata.models" /&gt;
      &lt;context:component-scan base-package="com.levadata" /&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/levadata_beta" /&gt;
       &lt;property name="username" value="root" /&gt;
      &lt;property name="password" value="root" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" /&gt;
  
      &lt;bean id="jpaVendorAdapter"
      class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
      &lt;/bean&gt;
  
        &lt;bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="persistenceUnitName" value="jcgPersistence" /&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="persistenceXmlLocation" value="META-INF/persistence.xml" /&gt;
      &lt;property name="jpaVendorAdapter" ref="jpaVendorAdapter" /&gt;
      &lt;property name="jpaDialect" ref="jpaDialect" /&gt;
      &lt;property name="jpaProperties"&gt;
       &lt;props&gt;
          &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
          &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/prop&gt;
          &lt;/props&gt;
       &lt;/property&gt;
    &lt;/bean&gt;
  
      &lt;bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="jpaDialect" ref="jpaDialect" /&gt;
     &lt;/bean&gt;
  
         &lt;tx:annotation-driven transaction-manager="txManager" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Here is my Employee.java(myPOJO):</p>
  
  <pre><code>@Entity
  @Table(name = "employee")
  public class Employee {
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = "employee_id")
  private long employeeId;
  
  @Column(name = "employee_name")
  private String employeeName;
  
  public Employee() {
  }
  
  public Employee(String employeeName) {
      this.employeeName = employeeName;
  }
  
  public long getEmployeeId() {
      return this.employeeId;
  }
  
  public void setEmployeeId(long employeeId) {
      this.employeeId = employeeId;
  }
  
  public String getEmployeeName() {
      return this.employeeName;
  }
  
  public void setEmployeeName(String employeeName) {
      this.employeeName = employeeName;
  }
  }
  </code></pre>
  
  <p>Here is my repository:</p>
  
  <blockquote>
  <pre><code>public interface EmployeeRepository extends JpaRepository&lt;Employee, Long&gt;
  {
    Employee save(Employee employee);
  
    //@Query("select distinct employee_name from employee")
    //public Slice&lt;String&gt; findAllDistinctNames(Pageable pageable);
    public Slice&lt;String&gt; findAllByEmployeeName(Pageable pageable);
  }
  </code></pre>
  </blockquote>
  
  <p>Finally My POM.xml:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" 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;com.levadata&lt;/groupId&gt;
  &lt;artifactId&gt;exampleLytica&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;name&gt;exampleLytica&lt;/name&gt;
  
  &lt;properties&gt;
      &lt;spring.version&gt;4.2.1.RELEASE&lt;/spring.version&gt;
      &lt;spring-data.version&gt;Gosling-RELEASE&lt;/spring-data.version&gt;
  
      &lt;!-- The main class to start by executing java -jar --&gt;
      &lt;start-class&gt;com.levadata.Application&lt;/start-class&gt;
  
  &lt;/properties&gt; 
  
  &lt;dependencyManagement&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
              &lt;artifactId&gt;spring-data-releasetrain&lt;/artifactId&gt;
              &lt;version&gt;${spring-data.version}&lt;/version&gt;
              &lt;scope&gt;import&lt;/scope&gt;
              &lt;type&gt;pom&lt;/type&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;
  
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
          &lt;artifactId&gt;gson&lt;/artifactId&gt;
          &lt;version&gt;2.3.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
          &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
          &lt;version&gt;4.5.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
          &lt;artifactId&gt;spring-data-jpa&lt;/artifactId&gt;
  
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
          &lt;artifactId&gt;tomcat-util&lt;/artifactId&gt;
          &lt;version&gt;8.0.0-RC1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.zaxxer&lt;/groupId&gt;
          &lt;artifactId&gt;HikariCP&lt;/artifactId&gt;
          &lt;version&gt;2.2.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- JPA Provider (Hibernate) --&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;5.1.37&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;dependency&gt;
           &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
           &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
           &lt;version&gt;5.0.2.Final&lt;/version&gt;
   &lt;/dependency&gt;
  
   &lt;!-- for JPA, use hibernate-entitymanager instead of hibernate-core --&gt;
   &lt;dependency&gt;
   &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
   &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
   &lt;version&gt;5.0.2.Final&lt;/version&gt;
   &lt;/dependency&gt;
  
   &lt;!-- optional --&gt;
  
  &lt;dependency&gt;
  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
  &lt;artifactId&gt;hibernate-osgi&lt;/artifactId&gt;
  &lt;version&gt;5.0.2.Final&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
  &lt;artifactId&gt;hibernate-envers&lt;/artifactId&gt;
  &lt;version&gt;5.0.2.Final&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
  &lt;artifactId&gt;hibernate-c3p0&lt;/artifactId&gt;
  &lt;version&gt;5.0.2.Final&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
  &lt;artifactId&gt;hibernate-proxool&lt;/artifactId&gt;
  &lt;version&gt;5.0.2.Final&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
  &lt;artifactId&gt;hibernate-infinispan&lt;/artifactId&gt;
  &lt;version&gt;5.0.2.Final&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
  &lt;artifactId&gt;hibernate-ehcache&lt;/artifactId&gt;
  &lt;version&gt;5.0.2.Final&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
  &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
  &lt;version&gt;5.2.2.Final&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.3&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.8&lt;/source&gt;
                  &lt;target&gt;1.8&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.6&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt;
                  &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>My Main method:</p>
  
  <pre><code>public static void main(String[] args)
      {
              try
              {
                      ApplicationContext context = new ClassPathXmlApplicationContext("spring-configuration.xml");
                      System.out.println("Context : " + context);
                      //Fetch the DAO from Spring Bean Factory
                      EmployeeRepository repository = (EmployeeRepository)context.getBean("employeeRepository");
                      Employee employee = new Employee("Employee123");
                      //employee.setEmployeeId("1");
  
                      //Save an employee Object using the configured Data source
                      repository.save(employee);
                      System.out.println("Employee Saved with EmployeeId "+employee.getEmployeeId());
  
                      //find an object using Primary Key
                      Employee emp = repository.findOne(employee.getEmployeeId());
                      System.out.println(emp);
  
                      //Close the ApplicationContext
                      ((ConfigurableApplicationContext)context).close();
  
              }
              catch (BeansException e)
              {
                      e.printStackTrace();
              }
      }
  </code></pre>
  
  <p>When I run the code, I am getting below stack trace:</p>
  
  <pre><code>org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined: No matching PlatformTransactionManager bean found for qualifier 'transactionManager' - neither qualifier match nor bean name match!
  at org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils.qualifiedBeanOfType(BeanFactoryAnnotationUtils.java:100)
  at org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils.qualifiedBeanOfType(BeanFactoryAnnotationUtils.java:56)
  at org.springframework.transaction.interceptor.TransactionAspectSupport.determineQualifiedTransactionManager(TransactionAspectSupport.java:377)
  at org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:361)
  at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:271)
  at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:119)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
  at com.sun.proxy.$Proxy20.save(Unknown Source)
  at com.levadata.SpringDataDemo.main(SpringDataDemo.java:26)
  </code></pre>
  
  <p>Any idea, which piece I am missing here.</p>