title: How can I use spring injection, A repository class in a mapstruct mapper?
body: <pre><code>@Data
  public class FilesDTO {
  
      private int issue;
      private String uniqueStr;
      private StorageDomain xml;
      private StorageDomain pdf;
      private StorageDomain stop;
  }
  @Data
  public class BackHalfDomain {
      private int articleId;
      private String uniqueStrr;
      private long xmlContentId;
      private long pdfContentId;
      private long stopId;
      private int issueNumber;
  }
  </code></pre>
  <p>Using a repository class I have to fetch a <code>StorageDomain</code> object from the ID in <code>BackHalfDomain</code>. So I have to map <code>StorageDomain</code> object with respective fields.
  like <code>StorgeDomain sd = repo.findById(id).get();</code> and set this <code>sd</code> object in <code>FilesDTO</code>'s xml field and so on.
  This is my mapper</p>
  <pre><code>@Mapper(componentModel = &quot;spring&quot;)
  public interface FilesDTOMapper {
  
      public static final FilesDTOMapper fileDTOMapper = Mappers.getMapper(FilesDTOMapper.class);
  
      @Mapping(target = &quot;issue&quot;, source = &quot;domain.issueNumber&quot;)
      @Mapping(target = &quot;DOI&quot;, source = &quot;domain.doi&quot;)
      public FilesDTO map(BackHalfDomain domain);
  
  }
  </code></pre>
  <p>I have used <code>uses</code> but wasn't successful.
  I have used <code>@Mapping(target=&quot;xyz&quot;, expression=&quot;java(repo.findById(id))&quot;)&quot;</code>
  but all I got was <code>NullPointerException</code>
  Spring injection isin't working.
  Can someone have a solution for this? I am just started with <code>mapstruct</code></p>