yooouuri
yooouuri

Reputation: 2658

WebSecurityConfigurerAdapter not found

My build.gradle contains:

compile('org.springframework.security:spring-security-web:4.1.3.RELEASE')

Did a "refresh all gradle projects" (im using IntelliJ!)

When i want to extend WebSecurityConfigurerAdapter it says "Create class ...."

The namespace where WebSecurityConfigurerAdapter should be is also not found...

See http://docs.spring.io/spring-security/site/docs/current/apidocs/org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter.html

Upvotes: 5

Views: 22302

Answers (5)

VHS
VHS

Reputation: 10184

If you are using a newer version (> 5.7.0) of spring-boot and hence spring-boot-starter-security, the class WebSecurityConfigurerAdapter is deprecated. See the notes on the GitHub issue. Now on you need to declare beans for each type of component (web, http, etc) that you are trying to configure security for.

Upvotes: 1

krishna
krishna

Reputation: 7

Add these dependencies in the pom file in the maven project.
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-test</artifactId>
    <scope>test</scope>
</dependency>

Upvotes: 0

Awn Ali
Awn Ali

Reputation: 1379

I faced this issue when I added the wrong dependency package from maven. By mistake, I added spring-security-web instead of spring-boot-starter-security.

Please add

spring-boot-starter-security

and it will work :)

Upvotes: 2

Arman Ahmed
Arman Ahmed

Reputation: 21

Simply you can do this :

import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

Upvotes: 0

Vadym Ozarynskyi
Vadym Ozarynskyi

Reputation: 335

add maven dependency spring config like this

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    <version>4.1.3.RELEASE</version>
</dependency>

or download jar and connect to your project

Upvotes: 7

Related Questions