title: Running integration tests with Spring boot (NoSuchBeanDefinitionException)
body: <p>I am trying to sort out the following issue.</p>
  
  <p>I've created a Spring Boot application which is also using Spring Data.
  To do integration tests, I want to power up an H2 database.</p>
  
  <p>I configured the test with <code>@ContextConfiguration</code> and referenced my applicationContext.xml file.</p>
  
  <p>When I am running the tests out of the IDE (intelliJ) everything is fine, and the test is getting grean.
  But as soon as I run the test on my build server or in the console with gradle, I get <code>NoSuchBeanDefinitionException</code>. It seems like the applicationContext is not considered at all...</p>
  
  <p>Actually I have no clue anymore what to do..</p>
  
  <p>My applicationContext-test.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:context="http://www.springframework.org/schema/context"
     xmlns:data="http://www.springframework.org/schema/data/jpa"
     xmlns="http://www.springframework.org/schema/beans"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
  &lt;context:annotation-config/&gt;
  &lt;context:component-scan base-package="de.company.project"/&gt;
  
  &lt;bean class=
   "org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/&gt;
  &lt;bean class=
   "org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"/&gt;
  &lt;bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="${database.driverClassName}"/&gt;
      &lt;property name="url" value="${database.url}"/&gt;
      &lt;property name="username" value="${database.username}"/&gt;
      &lt;property name="password" value="${database.password}"/&gt;
  &lt;/bean&gt;
  
  &lt;bean class="org.springframework.orm.jpa.JpaTransactionManager"
        id="transactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory"/&gt;
  &lt;/bean&gt;
  
  &lt;bean
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
   id="entityManagerFactory"&gt;
      &lt;property name="persistenceUnitName" value="persistenceUnit"/&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
      &lt;property name="persistenceXmlLocation" value="classpath:META-INF/persistence-
      test.xml"/&gt;
      &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
              &lt;property name="databasePlatform" value="org.hibernate.dialect.H2Dialect"/&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>My persistenc-test.xml:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
   &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
           xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
  http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;
  
  &lt;persistence-unit name="persistenceUnit"
                    transaction-type="RESOURCE_LOCAL"&gt;
      &lt;class&gt;de.company.project.server.model.Entity&lt;/class&gt;
  
      &lt;properties&gt;
         &lt;property name="hibernate.hbm2ddl.auto" value="create-drop" /&gt;
          &lt;property name="hibernate.ejb.naming_strategy"                   
          value="org.hibernate.cfg.ImprovedNamingStrategy" /&gt;
          &lt;property name="hibernate.connection.charSet" value="UTF-8" /&gt;
          &lt;property name="hibernate.default_schema" value="public" /&gt;
          &lt;property name="hibernate.show_sql" value="true" /&gt;
      &lt;/properties&gt;
      &lt;/persistence-unit&gt;
   &lt;/persistence&gt;
  </code></pre>
  
  <p>The database.properties just contains the defaults for an H2 database.</p>
  
  <p>And last but not least my Testclass</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration("classpath:*META-INF/applicationContext-test.xml")
  public class EntityServiceTest {
    @Test
    public void doSomeStuff(){
    }
  .
  .
  }
  </code></pre>
  
  <p>I hope somebody has a clue what I am doing wrong?!</p>
  
  <p>BR</p>
  
  <p>Edit:</p>
  
  <p>Missed to add the exception and the respository:</p>
  
  <pre><code> @Repository
   public interface EntityRepository extends JpaRepository&lt;Entity, Integer&gt; {
   }
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code> Caused by:                              
   org.springframework.beans.factory.NoSuchBeanDefinitionException: No 
   qualifying    
   bean of type [de.company.project.server.dao.EntityRepository] 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>