title: Spring Boot: Mapper not being initialized
body: <p>I'm building a Java app with Spring boot, and everything was good until I tried to implement Mappers...</p>
  
  <p>Apparently the mappers are not being initialized. I'm trying to implement this for the first time so I'm not sure if I'm missing something or where the issue is.</p>
  
  <p>This is the issue I get when trying <code>mvn spring-boot:run</code></p>
  
  <pre><code>Compilation failure: 
  [ERROR] /service/impl/ProductServiceImpl.java:[33,23] variable productMapper not initialized in the default constructor
  </code></pre>
  
  <p>The ProductMapper class is:</p>
  
  <pre><code>@Mapper(componentModel = "spring")
  public interface ProductMapper {
  
      @Mapping(target = "id", source = "product.id")
      @Mapping(target = "name", source = "product.name")
      @Mapping(target = "image", source = "product.image")
      ProductDTO toProductResponse(Product product);
  
      default List&lt;ProductDTO&gt; toProductDTOList(List&lt;Product&gt; productList) {
          if (productList == null || productList.isEmpty()) return emptyList();
          return productList.stream().map(this::toProductResponse).collect(toList());
      }
  }
  </code></pre>
  
  <p>So as far as I read in the documentation, I'm using the <code>@Mapper</code> annotation and defining a <code>default</code> method.</p>
  
  <p>But when I tried to use that in a service class like the following:</p>
  
  <pre><code>@Service
  @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
  public class ProductServiceImpl implements ProductService {
  
      ProductMapper productMapper;
  
  @Override
      public List&lt;ProductDTO&gt; get(String name, int page, int quantity){
          Page&lt;Product&gt; products = null;
          if(name.length() &gt; 0) {
              Product item = new Product();
              item.setName("%" + name + "%");
  
              products = this.productRepository.findAll(Example.of(item), PageRequest.of(page-1, quantity, Sort.by("name")));
          } else {
              products = this.productRepository.findAll(PageRequest.of(page-1, quantity, Sort.by("name")));
          }
  
          return productMapper.toProductDTOList(products.toList());
      }
  
  }
  </code></pre>
  
  <p>Also in my pom.xml I have the following plugins:</p>
  
  <pre><code>&lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.8.1&lt;/version&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;pre-integration-test&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;start&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                      &lt;execution&gt;
                          &lt;id&gt;post-integration-test&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;stop&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;includes&gt;
                          &lt;include&gt;**/*Int.java&lt;/include&gt;
                      &lt;/includes&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;integration-test&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;integration-test&lt;/goal&gt;
                              &lt;goal&gt;verify&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  </code></pre>
  
  <p>Could you please point me where the issue is?</p>