title: How to catch Spring bean creation error - Injection of autowired dependency?
body: <p>AdminService.java</p>
  
  <pre><code>    package service;
  
      import java.util.HashMap;
  
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Service;
  
      import dao.IAdminDAO;
      import dao.IMemberDAO;
  
      public interface AdminService
      {   
          public HashMap&lt;String, Object&gt; adminLogin(String id,String pw);
      }
  
  AdminServiceImple.java
      package service;
  
      import java.util.HashMap;
  
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Service;
  
      import dao.IAdminDAO;
  
      @Service
      public class AdminServiceImple implements AdminService
      {
  
          @Autowired
           private IAdminDAO adminDao;
  
          @Override
          public HashMap&lt;String, Object&gt; adminLogin(String id, String pw) 
          {
              HashMap&lt;String, Object&gt; adminResult = adminDao.selectOne(id);
  
              if(adminResult != null)
              {
                  String opwd = (String) adminResult.get("pw");
  
                  if(opwd.equals(pw))
                  {
                      if(adminResult.get("authority").equals(true))
                      {
                          return adminResult;
                      }
                      else
                      {
                          return null;
                      }
                  }
                  else
                  {
                      return null;
                  }
              }
              else
              {
                  return null;
              }
          }
      }
  
  AdminController.java
  
      package controller;
  
      import java.io.IOException;
      import java.util.HashMap;
  
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
      import javax.servlet.http.HttpSession;
  
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Controller;
      import org.springframework.web.bind.annotation.RequestMapping;
      import org.springframework.web.bind.annotation.RequestParam;
      import org.springframework.web.bind.annotation.ResponseBody;
      import org.springframework.web.servlet.ModelAndView;
  
      import service.AdminService;
      import service.AdminServiceImple;
      import service.MemberService;
  
      @Controller
      public class AdminController 
      {
          @Autowired
          public AdminServiceImple adminService;
  
          // 관리자 로그인 폼 페이지
          @RequestMapping("admin.do")
          public String adminLoginPage()
          {
              return "adminLoginPage";
          }
  
          // 관리자 로그인했을 시 요청
          @RequestMapping("adminLoginOK.do")
          @ResponseBody
          public String adminMainPage(@RequestParam(required=false) String id, @RequestParam(required=false)String pw,HttpSession session,HttpServletRequest req,HttpServletResponse resp)
          {
              HashMap&lt;String, Object&gt; adminLoginIdentify = adminService.adminLogin(id, pw);
  
              if(adminLoginIdentify != null)
              {
                  return "1";
              }
              else
              {
                  return "0";
              }
          }
  
          @RequestMapping("adminPage.do")
          public String adminPage(HttpSession session,HttpServletRequest resquest,HttpServletResponse response) throws IOException
          {
              return "adminMainPage";
          }
      }
  </code></pre>
  
  <p>applicationContext.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:context="http://www.springframework.org/schema/context"
      xmlns:jdbc="http://www.springframework.org/schema/jdbc"
      xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
      xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.3.xsd
          http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
          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-4.1.xsd"&gt;
  
      &lt;context:component-scan base-package="dao, service" /&gt;
  
      &lt;bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="dataSource"&gt;
          &lt;property value="com.mysql.jdbc.Driver" name="driverClassName"&gt;&lt;/property&gt;
          &lt;property value="jdbc:mysql://localhost/rachelvf" name="url"&gt;&lt;/property&gt;
          &lt;property value="root" name="username"/&gt;
          &lt;property value="mysql" name="password"/&gt;
      &lt;/bean&gt;
  
      &lt;bean class="org.mybatis.spring.SqlSessionFactoryBean"&gt;
          &lt;property name="mapperLocations" value="classpath:dao/mapper/*.xml"&gt;&lt;/property&gt;
          &lt;property name="typeAliasesPackage" value="model"&gt;&lt;/property&gt;
          &lt;property name="dataSource" ref="dataSource"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
     &lt;bean class="org.mybatis.spring.mapper.MapperFactoryBean"  id="memberDao"&gt;
       &lt;property name="mapperInterface" value="dao.IMemberDAO"&gt;&lt;/property&gt; 
        &lt;property name="sqlSessionFactory" ref="SqlSessionFactory"&gt;&lt;/property&gt;
     &lt;/bean&gt;
  
     &lt;bean class="org.mybatis.spring.mapper.MapperFactoryBean"  id="adminDao"&gt;
       &lt;property name="mapperInterface" value="dao.IAdminDAO"&gt;&lt;/property&gt; 
       &lt;property name="sqlSessionFactory" ref="SqlSessionFactory"&gt;&lt;/property&gt;
     &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>that is error code.</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminServiceImple': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private dao.IAdminDAO service.AdminServiceImple.adminDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [dao.IAdminDAO] 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)}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
  </code></pre>
  
  <p>I thought about the cause of the error, but I think it is because I did not insert the service annotation.</p>
  
  <p>However, there is no typos in any way, and everything is written correctly and errors occur. Is there something I don't know?</p>
  
  <p>Can you tell me what caused this error?</p>
  
  <p>And what about the solution?</p>