Configuring Spring Boot using Spring Security makes build failures due to a link to a missing dependency

When you try to run mvn install , in the Spring boot project, the assembly will fail due to:

  <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jersey</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> 

The goal of org.apache.maven.plugins failed: Maven-compiler-plugin: 3.3: compile (default compilation) on the project wave: fatal error compilation: java.lang.RuntimeException: com.sun.tools.javac.code. Symbol $ CompletionFailure: class file for org.springframework.security.ldap.DefaultSpringSecurityContextSource not found → [Help 1]

Two things solved this problem:

  • Removing the following security configuration

     @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); } } 

Removing the configuration from the command line is not an option, since it disables protection from my application.

  1. Adding the following dependency

     <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-ldap</artifactId> </dependency> 

However, adding that the error has disappeared, a new similar error has appeared (just pointing to another class):

The goal of org.apache.maven.plugins failed: Maven-compiler-plugin: 3.3: compile (default compilation) on the project wave: fatal error compilation: java.lang.RuntimeException: com.sun.tools.javac.code. Symbol $ CompletionFailure: class file for org.springframework.security.openid.OpenIDAttribute not found → [Help 1]

Eliminating this, I added the following dependency:

  <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-openid</artifactId> </dependency> 

This fixed the problem again, but another error appeared:

The goal of org.apache.maven.plugins failed: Maven-compiler-plugin: 3.3: compile (default compilation) on the project wave: fatal error compilation: java.lang.RuntimeException: com.sun.tools.javac.code. Symbol $ CompletionFailure: class file for org.apache.http.Header not found → [Help 1]

Finally, adding the following dependency, fixed all the problems:

  <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.1</version> </dependency> 

However, I now have several dependencies that I do not use.

Is there any other way to fix this problem?

+6
source share
2 answers

remove your dependency and add it; this works fine for me after i removed

 <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.1</version> </dependency> 

and

 <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-ldap</artifactId> 

here is my pom.xml file

  <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <exclusions> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.security.oauth</groupId> <artifactId>spring-security-oauth2</artifactId> <version>2.0.9.RELEASE</version> <type>jar</type> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.6</version> </dependency> </dependencies> 
+1
source

I solved this problem by replacing

 <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId> <version>2.6.4</version> <scope>provided</scope> </dependency> 

on

 <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>5.0.12.Final</version> </dependency> 

I think this problem is in org.eclipse.persistence.jpa.modelgen.processor

+1
source

All Articles