springspring-bootspring-mvcthymeleafspring-thymeleaf

setting WebSecurityConfig in SpringBoot app


I am setting WebSecurityConfig in SpringBoot app.

@Configuration
@EnableWebSecurity
public class  WebSecurityConfig extends WebSecurityConfigurerAdapter {

..
}

but I have this error Cannot resolve symbol 'WebSecurityConfigurerAdapter'

even I have this in the pom.xml:

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </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>

Solution

  • Since you're not setting the version to spring-boot-starter-security dependecy, it's problably using a newer version that as deprecated WebSecurityConfigurerAdapter class.

    Check the links for more details: