title: expected at least 1 bean which qualifies as autowire candidate for this dependency
body: <p>I am very new to spring and trying to developing one application in spring boot.I know this is duplicate question but I didnt find any solution to my problem..
  I have a class called <strong>UserController</strong>  which is like below  </p>
  
  <pre><code>    @RestController
      public class UserController {
  
          private static final Logger LOGGER = LoggerFactory.getLogger(UserController.class);
          private final UserService userService;
  
          DatabaseConnections dataconnections = new DatabaseConnections(); 
         @Autowired
         private DAO dao;      
          @Inject
          public UserController(final UserService userService) {
              this.userService = userService;  
          }
  
          @RequestMapping(value = "/user", method = RequestMethod.POST)
          public User createUser(@RequestBody @Valid final User user) {
              LOGGER.debug("Received request to create the {}", user);
              return userService.save(user);
          }
         @RequestMapping(value = "/getuser/{id}", method = RequestMethod.GET)
         public JSONObject getUser(@PathVariable String id) {
  
      return dao.getUsers(id);
      }
      }
  </code></pre>
  
  <p>I have one more class which is having some function :  </p>
  
  <pre><code>@Service("dao")
      public class DAO {    
        public JSONObject getUsers(@PathVariable String id) {
                  Connection dbConnection = null;
                  Statement statement = null;
                  JSONObject userJSONObject = new JSONObject();
                  String selectusers = "SELECT* from emp;
                  try {
                      dbConnection = dataconnections.getPostgresConnection(hostname, port, dbname, username, password);
                      statement = dbConnection.createStatement();
                      ResultSet rs = statement.executeQuery(selectusers);
                      while (rs.next()) {
                             --
                          ---
                      }
                      return userJSONObject;
      } 
  </code></pre>
  
  <p>I want to use the getUsers function in usercontroler class </p>
  
  <p>I am getting error below when I try to do by this way.  </p>
  
  <pre><code>    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of autowired dependencies  
     failed; nested exception is   
  org.springframework.beans.factory.BeanCreationException: Could not autowire  
   field: private com.emc.bdma.itaudemo.postgres.dao.DAO   
  com.emc.bdma.itaudemo.restclient.controller.UserController.dao; nested   
  exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:   
  No qualifying bean of type [com.emc.bdma.itaudemo.postgres.dao.DAO] 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>