title: Mapstruct generated class not being injected by Spring in JHipster web app
body: <p>I'm developing a web app created with JHipster v2.20.0.
  Using Eclipse 4.5.0 WTP as IDE.</p>
  
  <p>The Spring configuration is annotation based.</p>
  
  <p>I've just merged <a href="https://github.com/jhipster/generator-jhipster/pull/1803" rel="noreferrer">this pull</a> with our code.</p>
  
  <p>When I try to run the application inside Eclipse I get this exception:</p>
  
  <pre><code>[INFO] com.app.tenancy.hibernate.MyCurrentTenantIdentifierResolver - MyCurrentTenantIdentifierResolver.getTenantId(): Couldn't find Company/Tenant for the domain inventario, stopping serving the request
  [WARN] org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userManagementResource': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.app.web.rest.mapper.UserManagementMapper com.app.web.rest.UserManagementResource.userManagementMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.app.web.rest.mapper.UserManagementMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.inject.Inject()}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) [spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) [spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) [spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
      at com.app.Application.main(Application.java:79) [classes/:na]
  Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.app.web.rest.mapper.UserManagementMapper com.app.web.rest.UserManagementResource.userManagementMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.app.web.rest.mapper.UserManagementMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.inject.Inject()}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      ... 14 common frames omitted
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.app.web.rest.mapper.UserManagementMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.inject.Inject()}
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
      ... 16 common frames omitted
  </code></pre>
  
  <p>This is the UserManagementMapper class:</p>
  
  <pre><code>package com.app.web.rest.mapper;
  
  import java.util.List;
  import java.util.Optional;
  
  import javax.inject.Inject;
  
  import org.mapstruct.Mapper;
  import org.mapstruct.Mapping;
  import org.mapstruct.MappingTarget;
  
  import com.app.domain.User;
  import com.app.service.UserService;
  import com.app.web.rest.dto.UserManagementDTO;
  
  @Mapper(componentModel = "spring", uses = {})
  public abstract class UserManagementMapper {
  
      @Inject
      private UserService userService;
  
      public abstract UserManagementDTO userToUserManagementDTO(User user);
      public abstract List&lt;UserManagementDTO&gt; usersToUserManagementsDTO(List&lt;User&gt; users);
  
      @Mapping(target = "createdBy", ignore=true)
      @Mapping(target = "createdDate", ignore=true)
      @Mapping(target = "lastModifiedBy", ignore=true)
      @Mapping(target = "lastModifiedDate", ignore=true)
      @Mapping(target = "persistentTokens", ignore=true)
      @Mapping(target = "resetDate", ignore=true)
      @Mapping(target = "activationKey", ignore=true)
      @Mapping(target = "resetKey", ignore=true)
      @Mapping(target = "password", ignore=true)
      public abstract User updateUserFromDto(UserManagementDTO userManagementDTO, @MappingTarget User user);
  
  
  
      public User userManagementDTOToUser(UserManagementDTO userManagementDTO) {
          return  Optional.ofNullable(userService.getUserWithAuthorities(userManagementDTO.getId()))
              .map(user -&gt; this.updateUserFromDto(userManagementDTO, user))
              .orElse(null);
      }
  }
  </code></pre>
  
  <p>This is the UserManagementResource class:</p>
  
  <pre><code>package com.app.web.rest;
  
  import java.net.URISyntaxException;
  import java.util.LinkedList;
  import java.util.List;
  import java.util.Optional;
  import java.util.stream.Collectors;
  
  import javax.annotation.security.RolesAllowed;
  import javax.inject.Inject;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.data.domain.Page;
  import org.springframework.http.HttpHeaders;
  import org.springframework.http.HttpStatus;
  import org.springframework.http.MediaType;
  import org.springframework.http.ResponseEntity;
  import org.springframework.transaction.annotation.Transactional;
  import org.springframework.transaction.annotation.Transactional;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.bind.annotation.RestController;
  
  import com.codahale.metrics.annotation.Timed;
  import com.app.domain.User;
  import com.app.repository.UserRepository;
  import com.app.security.AuthoritiesConstants;
  import com.app.service.UserService;
  import com.app.web.rest.dto.UserManagementDTO;
  import com.app.web.rest.mapper.UserManagementMapper;
  import com.app.web.rest.util.PaginationUtil;
  
  /**
   * REST controller for managing users.
   */
  @RestController
  @RequestMapping("/api")
  public class UserManagementResource {
  
      private final Logger log = LoggerFactory.getLogger(UserManagementResource.class);
  
      @Inject
      private UserService userService;
  
      @Inject
      private UserRepository userRepository;
  
      @Autowired
      private UserManagementMapper userManagementMapper;
  
      /**
       * GET  /userManagement -&gt; get all users to manage.
       */
      @RequestMapping(value = "/userManagement",
          method = RequestMethod.GET,
          produces = MediaType.APPLICATION_JSON_VALUE)
      @Timed
      @RolesAllowed(AuthoritiesConstants.ADMIN)
      @Transactional(readOnly = true)
      public ResponseEntity&lt;List&lt;UserManagementDTO&gt;&gt; getAll(@RequestParam(value = "page" , required = false) Integer offset,
                                                           @RequestParam(value = "per_page", required = false) Integer limit)
          throws URISyntaxException {
          Page&lt;User&gt; page = userRepository.findAll(PaginationUtil.generatePageRequest(offset, limit));
          HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/userManagement", offset, limit);
          return new ResponseEntity&lt;&gt;(page.getContent().stream()
                   .map(userManagementMapper::userToUserManagementDTO)
                   .collect(Collectors.toCollection(LinkedList::new)), headers, HttpStatus.OK);
      }
  
      /**
       * GET  /userManagement/:id -&gt; get id user to manage.
       */
      @RequestMapping(value = "/userManagement/{id}",
              method = RequestMethod.GET,
              produces = MediaType.APPLICATION_JSON_VALUE)
      @Timed
      @RolesAllowed(AuthoritiesConstants.ADMIN)
      @Transactional(readOnly = true)
      ResponseEntity&lt;UserManagementDTO&gt; getUser(@PathVariable Long id) {
         log.debug("REST request to get User to manage : {}", id);
         return  Optional.ofNullable(userService.getUserWithAuthorities(id))
                 .map(userManagementMapper::userToUserManagementDTO)
                 .map(userManagementDTO -&gt; new ResponseEntity&lt;&gt;(
                      userManagementDTO,
                      HttpStatus.OK))
                 .orElse(new ResponseEntity&lt;&gt;(HttpStatus.NOT_FOUND));
      }
  
      /**
       * PUT  /userManagement -&gt; Updates an existing user.
       */
      @RequestMapping(value = "/userManagement",
          method = RequestMethod.PUT,
          produces = MediaType.APPLICATION_JSON_VALUE)
      @Timed
      @RolesAllowed(AuthoritiesConstants.ADMIN)
      public ResponseEntity&lt;Void&gt; update(@RequestBody UserManagementDTO userManagementDTO) throws URISyntaxException {
          log.debug("REST request to update User : {}", userManagementDTO);
          if (userManagementDTO.getId() == null) {
              return ResponseEntity.badRequest().header("Failure", "You cannot create a new user").build();
          }
          User user = userManagementMapper.userManagementDTOToUser(userManagementDTO);
          userRepository.save(user);
          return ResponseEntity.ok().build();
      }
  }
  </code></pre>
  
  <p>Lastly, the pom.xml file was not changed during this merge. The application was working properly before the merge.</p>
  
  <p>It's probably some newbie question, but I've lost more hours trying to solve this than performing the merge.</p>
  
  <p>Thanks in advance for any help!</p>