Good day. In pom.xml there is the following list of dependencies:

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> ... <!-- Add Spring Security --> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> <version>3.2.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>3.2.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>3.2.4.RELEASE</version> </dependency> <!-- Add Jstl Dependencies --> <dependency> <groupId>org.apache.taglibs</groupId> <artifactId>taglibs-standard-jstlel</artifactId> <version>1.2.1</version> </dependency> ... </project> 

I am writing a configuration for spring-security:

 package ru.project.configuration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; @Configuration @EnableWebSecurity public class AppSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication().withUser("user").password("user").roles("USER"); auth.inMemoryAuthentication().withUser("admin").password("admin").roles("ADMIN"); auth.inMemoryAuthentication().withUser("superadmin").password("superadmin").roles("SUPERADMIN"); } @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .antMatchers("/protected/**").access("hasRole('ROLE_ADMIN')") .antMatchers("/confidential/**").access("hasRole('ROLE_SUPERADMIN')") .and().formLogin().defaultSuccessUrl("/", false); } } 

But Idea cannot find the EnableWebSecurity annotation, nor the WebSecurityConfigurerAdapter class. What could be the problem?

Here is the result of mvn compile -X:

https://note-pad.net/ru/secretlink/fcf05f327dc9b6cf0296aac0501c8f07?page=1

  • Does maven build a project without problems? - Mikhail Vaysman
  • With maven install: cannot find symbol symbol: class WebSecurityConfigurerAdapter - ks_on_v
  • and maven downloaded dependences? can you find them in the local repository? - Mikhail Vaysman
  • Well, so maybe you did not enter the lib in which the WebSecurityConfigurerAdapter is located in pom.xml? - FORTRAN

2 answers 2

Add to class

 import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 
  • Already on the word security idea says that it cannot recognize the symbol. - ks_on_v
  • run mvn compile -X and add the result of the execution to the question. - Mikhail Vaysman
  • Added result to the question text - ks_on_v
  • add the full result, not a piece. - Mikhail Vaysman
  • Attached a link to the entire output in the console. there are 60,000 characters. Topics only 30,000 may contain. - ks_on_v

I went to pom.xml, clicked the right button, chose maven -> Reimport in the pop-up menu and the dependencies were connected.