본문 바로가기

JAVA/Spring-Error

[Spring boot 에러] @EnableWebSecurity cannot be resolved to a type spring boot 원인 및 해결

스프링 시큐리티 어노테이션을 추가하려고

 

@EnableWebSecurity

을 클래스에 추가하였는데 제목처럼

 

cannot be resolved to a type spring boot 라고 나오는 경우에는 dependency 를 확인해보자.

 

pom.xml / dependencies 목록에서

 

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

 

위 내용이 있는지 확인 후 없다면 추가해준다.

 

그리고 다시 import 해보면 된다.

 

그래도 해결이 안되는 경우

 

parent version 을 확인 해보자.