title: Spring Boot Multimodule Inject Error
body: <p>I've found numerous questions on this problem but none of the solutions worked for me. This project worked without any problems when it was a single module application. When I split the files into different modules I could no longer run it.</p>
  
  <p>The module structure:</p>
  
  <pre><code>root
  |
  |_api
  |   \_com.example.utils.mappers.MyObjectMapper.java
  |
  |
  |_persistence
  |
  |_rest
  |   \_com.example.Application.java
  |
  \_service
      \_com.example.service.MyObjectServiceImpl.java
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>Field myObjectMapper in com.example.service.MyObjectServiceImpl required a bean 
  of type 'com.example.utils.mappers.MyObjectMapper' that could not be found.
  </code></pre>
  
  <p>The two files in question, MyObjectMapper:</p>
  
  <pre><code>package com.example.utils.mappers;
  
  @Mapper(componentModel = "spring")
  public interface myObjectMapper {
    // some mapping functionality
  }
  </code></pre>
  
  
  
  <p>And the Service class:</p>
  
  <pre><code>package com.example.service;
  
  @Service
  public class MyObjectServiceImpl implements MyObjectService {
  
     @Inject
     private MyObjectMapper myObjectMapper;
  
     /* some DAO calls */
  }
  </code></pre>
  
  <p>The class that runs it all:</p>
  
  <pre><code>package com.example;
  
  @SpringBootApplication(scanBasePackages = "com.example"}
  public class Application extends SpringBootServletInitializer {
    /* call to SpringApplication run method */
  }
  </code></pre>
  
  <p>Example of root/pom.xml</p>
  
  <pre><code>&lt;groupId&gt;com.example&lt;/groupId&gt;
  &lt;artifactId&gt;root&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
  &lt;packaging&gt;pom&lt;/packaging&gt;
  
  &lt;modules&gt;
      &lt;module&gt;persistence&lt;/module&gt;
      &lt;module&gt;api&lt;/module&gt;
      &lt;module&gt;service&lt;/module&gt;
      &lt;module&gt;rest&lt;/module&gt;
  &lt;/modules&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.0.3.RELEASE&lt;/version&gt;
  &lt;/parent&gt;
  </code></pre>
  
  <p>Example of service/pom.xml:</p>
  
  <pre><code>&lt;groupId&gt;com.example&lt;/groupId&gt;
  &lt;artifactId&gt;service&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;com.example&lt;/groupId&gt;
      &lt;artifactId&gt;root&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;relativePath&gt;../&lt;/relativePath&gt;
  &lt;/parent&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.example&lt;/groupId&gt;
          &lt;artifactId&gt;api&lt;/artifactId&gt;
          &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>