Spring JUnit not loading whole applicationContext from XML
<p>I have created a JUnit test in spring with next code:</p>

<pre><code>@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
     "classpath:*/WEB-INF/demo-servlet.xml"})
public class CrudTestJUnit extends AbstractJUnit4SpringContextTests  {

    @Autowired 
    protected ShoppingCartDao shoppingCartDao; 

    @Autowired
    private ApplicationContext context;

    @Before
    public void setUp(){

    }

    @Test
    public void testSomething() {
        System.out.println("Evo beanvoa:" + Arrays.toString(context.getBeanDefinitionNames()));
        Assert.assertTrue(false);
    }
}
</code></pre>

<p>In demo-servlet.xml i defined bean:</p>

<pre><code>  &lt;bean id="shoppingCartDao" class="com.it355.hibernatecrud.dao.impl.ShoppingCartDaoImpl"&gt;&lt;/bean&gt;
</code></pre>

<p>When i run JUnit test i get this error:</p>

<pre><code>Error creating bean with name 'CrudTestJUnit': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected com.it355.hibernatecrud.dao.ShoppingCartDao CrudTestJUnit.shoppingCartDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.it355.hibernatecrud.dao.ShoppingCartDao] found for dependency:
</code></pre>

<p>When i delete shopping cart i get this from getBeanDefinitionNames():</p>

<pre><code>    Evo beanvoa:[org.springframework.context.annotation.internalConfigurationAnnotationProcessor, 
org.springframework.context.annotation.internalAutowiredAnnotationProcessor, 
org.springframework.context.annotation.internalRequiredAnnotationProcessor, 
org.springframework.context.annotation.internalCommonAnnotationProcessor, 
org.springframework.context.annotation.internalPersistenceAnnotationProcessor, 
org.springframework.context.event.internalEventListenerProcessor, 
org.springframework.context.event.internalEventListenerFactory, 
org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor, org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor]
</code></pre>

<p>Here is my full demo-servlet.xml file:</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:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-4.0.xsd
                           http://www.springframework.org/schema/mvc 
                   http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
                           http://www.springframework.org/schema/tx 
                           http://www.springframework.org/schema/tx/spring-tx.xsd"&gt;

    &lt;!--Kako bi Hibernate mogao da se poveže na bazu podataka potrebno je kreirati sesiju. To radimo u sledećem
    zrnu--&gt;
    &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
        &lt;property name="configLocation" &gt;
            &lt;!--Dodavanje path-a na kome se nalaze podešavanja za Hibernate --&gt;
            &lt;value&gt;classpath:hibernate.cfg.xml&lt;/value&gt;
        &lt;/property&gt;
        &lt;!-- Dodavanje path-a paketa u kome se nalaze entity fajlovi na osnovu kojih
        će Hibernate kreirati bazu i upisivati u nju--&gt;
        &lt;property name="packagesToScan"&gt;
            &lt;list&gt;
                &lt;value&gt;com.it355.hibernatecrud.entity&lt;/value&gt;
            &lt;/list&gt;
        &lt;/property&gt;
    &lt;/bean&gt;

    &lt;!--Transakcija se dešava između baze i programa korišćenjem Transaction Managera koji definišemo ovde
    On koristi sesiju koju smo definisali iznad    --&gt;
    &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;

    &lt;bean id="transactionManager"  class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
        &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
    &lt;/bean&gt;

    &lt;bean id="shoppingCartDao" class="com.it355.hibernatecrud.dao.impl.ShoppingCartDaoImpl"&gt;&lt;/bean&gt;
    &lt;bean id="persistenceExceptionTranslationPostProcessor"
          class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/&gt;

    &lt;context:component-scan base-package="com.it355.hibernatecrud" /&gt;
    &lt;mvc:annotation-driven conversion-service="conversionService" /&gt;
    &lt;tx:annotation-driven /&gt;

    &lt;mvc:default-servlet-handler /&gt;

    &lt;mvc:resources mapping="/css/**" location="/WEB-INF/css/"/&gt;
    &lt;mvc:resources mapping="/resources/**" location="/WEB-INF/" /&gt;
    &lt;bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"&gt;
        &lt;property name="converters"&gt;
            &lt;set&gt;
                &lt;bean class="com.it355.hibernatecrud.converter.IntegerToCategory" /&gt;
            &lt;/set&gt;
        &lt;/property&gt;
    &lt;/bean&gt;
    &lt;bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
        &lt;property name="prefix" value="/WEB-INF/jsp/"&gt;&lt;/property&gt;
        &lt;property name="suffix" value=".jsp"&gt;&lt;/property&gt;
    &lt;/bean&gt;

&lt;/beans&gt;
</code></pre>

<p>Am i wrong in calling configuration file or some other thing? Is there someone who had the same issue. </p>

<p>Also in my configuration file i have component scan configured and my application works and loads beans without any problem but JUnit is making a problem.</p>