Reputation: 12750
I have a Maven demo project for which I use some Spring Security features.
I could import the project fine into Eclipse STS and the editor shows no error related to dependencies.
But a Maven command to compile on the command line fails.
I get the following errors:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project learnintouch-web: Compilation failure: Compilation failure:
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[7,78] package org.springframework.security.config.annotation.authentication.builders does not exist
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[8,67] package org.springframework.security.config.annotation.web.builders does not exist
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[9,72] package org.springframework.security.config.annotation.web.configuration does not exist
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[10,72] package org.springframework.security.config.annotation.web.configuration does not exist
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[19,47] cannot find symbol
[ERROR] symbol: class WebSecurityConfigurerAdapter
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[15,2] cannot find symbol
[ERROR] symbol: class EnableWebSecurity
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[25,34] cannot find symbol
[ERROR] symbol: class AuthenticationManagerBuilder
[ERROR] location: class com.thalasoft.learnintouch.web.config.WebSecurityConfiguration
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[24,9] method does not override or implement a method from a supertype
Here is in the pom.xml the Spring Security dependencies:
<org.springframework.security.version>3.2.4.RELEASE</org.springframework.security.version>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${org.springframework.security.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
Upvotes: 9
Views: 40735
Reputation: 1687
I could solve this by adding the latest possible compatible versions of Spring framework.version and Spring Security.version.
Ex:
<properties>
<springframework.version>5.1.1.RELEASE</springframework.version>
<springsecurity.version>5.1.1.RELEASE</springsecurity.version>
</properties>
Also in the dependencies, I added the below:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>5.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>5.1.1.RELEASE</version>
</dependency>
Now it worked fine.
Upvotes: 3
Reputation: 11449
If you have spring boo project add following dependency ,Seems like Spring security jar is missing
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Upvotes: 0
Reputation: 31
It seems version conflict problem. I faced same problem and could solve it by changing spring-security version from 3.1.7 to 3.2.4. Hope it may help someone.
Upvotes: 2
Reputation: 74
in my case this error was caused by version conflict
had java 8 maven app , changed version to java7 and made mvn eclipse:eclipse from cmd it was running but from eclipse giving error: WebSecurityConfigurerAdapter cannot be resolved to a type
after project was showing all jars and work was not easy security jars were not shown was giving error : WebSecurityConfigurerAdapter cannot be resolved to a type
right click from menu choose: configure -> convert to maven project after right click project and choose properties->java build path : check for java version ,remove incorrect java version with button [add library] change to ide's java version still in properties window choose: java compiler compiler compliance level group change to ide's java version where it is showing incorrect version
that is it
Upvotes: 0
Reputation: 9145
I resolved this by removing this line from pom.xml
on the spring-security-config
artifact:
<scope>runtime</scope>
Upvotes: 11
Reputation: 105
I ran into the same issue going through some Spring Security tutorials. This is due to versioning conflicts.
Update your POM to remove the version info for all the Spring dependencies. Then throw in the spring-framework-bom to handle your versioning and it should work.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.0.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Upvotes: 0
Reputation: 12750
I overhauled the dependencies and the build now passes. There was some conflict between Spring dependencies.
Upvotes: -1
Reputation: 81
You need to add spring security library manually.
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
Upvotes: 8