title: Spring Boot / MapStruct: Parameter 1 of constructor required a bean... Consider defining a bean of type
body: <p>I don't know so much about Java, but I thought it should be enough to manage this little task...</p>
  <p>I'm building a microservice, which provides Songs and list of songs via several Rest-Endpoints. But it doesn't just return a song when called, it also has to contact another service and enhance the song object with additional information. For this I implemented a Dto-Class and I use mapstruct to handle logic behind. I also did this in other projects with no problems. But now I'm struggling, because of this error, which I don't know how to solve - it says:</p>
  <blockquote>
  <p>Parameter 1 of constructor in
  mk.microservices.songsservice.services.SongServiceImpl required a bean
  of type 'mk.microservices.songsservice.web.mapper.SongMapper' that
  could not be found.</p>
  <p>Action:</p>
  <p>Consider defining a bean of type
  'mk.microservices.songsservice.web.mapper.SongMapper' in your
  configuration.</p>
  </blockquote>
  <p>Here are excerpts from my code:</p>
  <p><strong>SongServiceImpl</strong></p>
  <pre><code>import lombok.RequiredArgsConstructor;
  import mk.microservices.songsservice.domain.Song;
  import mk.microservices.songsservice.repositories.SongRepository;
  import mk.microservices.songsservice.web.mapper.SongMapper;
  import mk.microservices.songsservice.web.model.SongDto;
  import org.springframework.stereotype.Service;
  
  import java.util.List;
  import java.util.Optional;
  
  @RequiredArgsConstructor
  @Service
  public class SongServiceImpl implements SongService {
  
      private final SongRepository songRepository;
      private final SongMapper songMapper;
  
      @Override
      public SongDto getSongById(Integer id) {
          return songMapper.songToSongDto(songRepository.findById(id));
      }
  
      @Override
      public List&lt;Song&gt; getAllSongs() {
          return songRepository.findAll();
      }
  ....
  }
  </code></pre>
  <p><strong>SongMapper</strong></p>
  <pre><code>import org.mapstruct.DecoratedWith;
  
  import java.util.Optional;
  
  @MapStruct
  @DecoratedWith(SongMapperDecorator.class)
  public interface SongMapper {
  
      SongDto songToSongDto(Optional&lt;Song&gt; song);
      SongDto songToSongDtoWithSongInfo(Song song);
      Song songDtoToSong(SongDto songDto);
  }
  </code></pre>
  <p><strong>SongMapperDecorator</strong></p>
  <pre><code>import org.springframework.beans.factory.annotation.Autowired;
  
  import java.util.Optional;
  
  public class SongMapperDecorator implements SongMapper {
  
      private SongInfoService songInfoService;
      private SongMapper mapper;
  
      @Autowired
      public void setMapper(SongMapper songMapper) { this.mapper = songMapper; }
  
      @Override
      public SongDto songToSongDto(Optional&lt;Song&gt; song) {
          return mapper.songToSongDto(song);
      }
  
      @Override
      public SongDto songToSongDtoWithSongInfo(Song song) {
          SongDto songDto = mapper.songToSongDto(Optional.ofNullable(song));
          SongInfo songInfo = songInfoService.getSongInfoBySongId(song.getId());
          songDto.setDescription(songInfo.getDescription());
          return songDto;
      }
  
      @Override
      public Song songDtoToSong(SongDto songDto) {
          return mapper.songDtoToSong(songDto);
      }
  }
  </code></pre>
  <p>Also did a clean, validate and compile without any errors. But when I did the verify, I got this:</p>
  <blockquote>
  <p>[ERROR] Failed to execute goal
  org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile
  (default-compile) on project songs-service: Resolution of
  annotationProcessorPath dependencies failed: Missing: [ERROR]
  ---------- [ERROR] 1) org.mapstruct:mapstruct-processor:jar:1.4.2</p>
  </blockquote>
  <p><strong>My POM looks like this:</strong></p>
  <p><strong>The dependency for mapstruct:</strong></p>
  <pre><code>&lt;dependency&gt;
          &lt;groupId&gt;org.mapstruct&lt;/groupId&gt;
          &lt;artifactId&gt;mapstruct&lt;/artifactId&gt;
          &lt;version&gt;1.4.2.Final&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  <p><strong>And the plugin for enabling mapstruct and lombok working together:</strong></p>
  <pre><code>&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.0&lt;/version&gt;
          &lt;configuration&gt;
              &lt;annotationProcessorPaths&gt;
                  &lt;path&gt;
                      &lt;groupId&gt;org.mapstruct&lt;/groupId&gt;
                      &lt;artifactId&gt;mapstruct-processor&lt;/artifactId&gt;
                      &lt;version&gt;${mapstruct.version}&lt;/version&gt;
                  &lt;/path&gt;
                  &lt;path&gt;
                       &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
                       &lt;artifactId&gt;lombok&lt;/artifactId&gt;
                       &lt;version&gt;${lombok.version}&lt;/version&gt;
                   &lt;/path&gt;
              &lt;/annotationProcessorPaths&gt;
              &lt;compilerArgs&gt;
                  &lt;compilerArg&gt;
                      -Amapstruct.defaultComponentModel=spring
                  &lt;/compilerArg&gt;
              &lt;/compilerArgs&gt;
          &lt;/configuration&gt;
      &lt;/plugin&gt;
  </code></pre>
  <p>Would be very glad, if someone could help me solving this. Already googled a lot and didn't find anything useful yet.</p>
  <p>Br,
  Mic</p>