title: Configuring Spring Boot with Spring Security makes build fail due to reference to missing dependency
body: <p>Whenever trying to run <code>mvn install</code>, on a Spring Boot project the build fails due to:</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-jersey&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <blockquote>
    <p>Failed to execute goal
    org.apache.maven.plugins:maven-compiler-plugin:3.3:compile
    (default-compile) on project wave: Fatal error compiling:
    java.lang.RuntimeException:
    com.sun.tools.javac.code.Symbol$CompletionFailure: class file for
    org.springframework.security.ldap.DefaultSpringSecurityContextSource
    not found -> [Help 1]</p>
  </blockquote>
  
  <p>Two things solved this issue:</p>
  
  <ol>
  <li><p><strong>Deleting</strong> the following security configuration</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
  
    @Inject
    private UserDetailsService userDetailsService;
  
    @Inject
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
      auth
        .userDetailsService(userDetailsService);
    }
  
    @Override
    protected void configure(HttpSecurity http) throws Exception {
      http
        .httpBasic()
          .realmName("Wave")
          .and()
        .authorizeRequests()
          .antMatchers(HttpMethod.POST, "/wave/service/employees/**").anonymous()
          .antMatchers("/wave/service/**").authenticated()
          .and()
        .sessionManagement()
          .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
    }
  
  }
  </code></pre></li>
  </ol>
  
  <p>Of coruse, removing the configuration is not an option since it disables security from my application</p>
  
  <ol start="2">
  <li><p><strong>Adding</strong> the following dependency</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
      &lt;artifactId&gt;spring-security-ldap&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre></li>
  </ol>
  
  <p>However, while adding it made the error disappear, a new similar error (just pointing to another class) appeared:</p>
  
  <blockquote>
    <p>Failed to execute goal
    org.apache.maven.plugins:maven-compiler-plugin:3.3:compile
    (default-compile) on project wave: Fatal error compiling:
    java.lang.RuntimeException:
    com.sun.tools.javac.code.Symbol$CompletionFailure: class file for
    org.springframework.security.openid.OpenIDAttribute not found -> [Help
    1]</p>
  </blockquote>
  
  <p>Fixing this again, I added the following dependency:</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-openid&lt;/artifactId&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>This fixed the issue again, but another error appeared:</p>
  
  <blockquote>
    <p>Failed to execute goal
    org.apache.maven.plugins:maven-compiler-plugin:3.3:compile
    (default-compile) on project wave: Fatal error compiling:
    java.lang.RuntimeException:
    com.sun.tools.javac.code.Symbol$CompletionFailure: class file for
    org.apache.http.Header not found -> [Help 1]</p>
  </blockquote>
  
  <p>Finally, adding the following dependency fixed all the issues:</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
          &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
          &lt;version&gt;4.5.1&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>However, I now have multiple dependencies I am not <em>using</em>.</p>
  
  <p>Is there another way to fix this issue?</p>