title: How to solve - Error creating bean with name 'defaultController'
body: <p>I am new to <strong>Spring MVC</strong> and <strong>Hibernate</strong>. For several days i am trying to make a simple spring project but got some error there. The error says <em>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'CustomerDAOImp'</em></p>
  
  <p>Here is my error</p>
  
  <blockquote>
    <p>HTTP Status 500 - Internal Server Error</p>
    
    <p>type Exception report</p>
    
    <p>messageInternal Server Error</p>
    
    <p>descriptionThe server encountered an internal error that prevented it
    from fulfilling this request.</p>
    
    <p>exception</p>
    
    <p>javax.servlet.ServletException: Servlet.init() for servlet dispatcher
    threw exception root cause</p>
    
    <p>org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name 'CustomerDAOImp': Unsatisfied dependency
    expressed through field 'sessionFactory'; nested exception is
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    qualifying bean of type 'org.hibernate.SessionFactory' available:
    expected at least 1 bean which qualifies as autowire candidate.
    Dependency annotations:
    {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    root cause</p>
    
    <p>org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    qualifying bean of type 'org.hibernate.SessionFactory' available:
    expected at least 1 bean which qualifies as autowire candidate.
    Dependency annotations:
    {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    note The full stack traces of the exception and its root causes are
    available in the GlassFish Server Open Source Edition 4.1.1 logs.</p>
    
    <p>GlassFish Server Open Source Edition 4.1.1</p>
  </blockquote>
  
  <p>I have used maven multi module to done this project. Here 'CustomerDAOImp' is the name of repository that i have defined in the CustomerDAOImp class. This is the java class that extends GenericImp class and implements CustomerDAO interface and further CustomerDAO extends the GenericDAO interface.  </p>
  
  <p><strong>CustomerDAOImp</strong></p>
  
  <pre><code>@Repository(value = "CustomerDAOImp")
  public class CustomerDAOImp extends GenericDAOImp&lt;Customer&gt; implements CustomerDAO{
  
  }
  </code></pre>
  
  <p><strong>CustomerDAO</strong></p>
  
  <pre><code>public interface CustomerDAO extends GenericDAO&lt;Customer&gt;{
  
  }
  </code></pre>
  
  <p><strong>GenericDAO</strong></p>
  
  <pre><code>public interface GenericDAO&lt;T&gt; {
      void insert(T t);
      void update(T t);
      boolean delete(int id);
      List&lt;T&gt; getAll();
      T getById(int id);
  }
  </code></pre>
  
  <p>And my controller for mapping jsp page</p>
  
  <pre><code>@Controller
  public class DefaultController {
      @Autowired
      CustomerDAOImp customerDaoImp;
  
      @RequestMapping(value = "/", method = RequestMethod.GET)
      public String index() {
          return "user/dairy/index";
      }
  
      @RequestMapping(value = "/customer", method = RequestMethod.GET)
      public String customer(Model model) {
          model.addAttribute("customer", customerDaoImp.getAll());
          return "user/dairy/customer";
      }
  }
  </code></pre>
  
  <p><strong>dispatcher-servlet.xml</strong></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:p="http://www.springframework.org/schema/p"
  
         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/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
  "&gt;
  
      &lt;context:component-scan base-package="com.nishan.dairy"/&gt;
      &lt;mvc:annotation-driven/&gt;
      &lt;mvc:resources mapping="/static/**" location="/WEB-INF/assets/"/&gt;
  
      &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
      p:prefix="/WEB-INF/views/" p:suffix=".jsp"/&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>applicationContext.xml</strong></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:p="http://www.springframework.org/schema/p"
         xmlns:security="http://www.springframework.org/schema/security"
  
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
              http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
  "&gt;
      &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
      p:location="/WEB-INF/db/jdbc.properties"/&gt;
  
      &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
      p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
      p:username="${jdbc.username}" p:password="${jdbc.password}"/&gt;
  
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource"/&gt;
          &lt;property name="packagesToScan" value="com.nishan.dairyreport.entity"/&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;
                      org.hibernate.dialect.MySQLDialect
                  &lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>Here is my project structure</strong></p>
  
  <p><a href="https://i.stack.imgur.com/UcPbr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UcPbr.png" alt="**Here is my project structure**"></a></p>
  
  <p><strong>Hoping for the positive response thanks...........</strong></p>