Spring Security - не может получить доступ к javax.servlet.filterJAVA

Программисты JAVA общаются здесь
Anonymous
Spring Security - не может получить доступ к javax.servlet.filter

Сообщение Anonymous »

Я пишу проект Spring Boot с базовой аутентификацией и авторизацией, используя Spring Security. У меня есть класс конфигурации, который расширяет WebseCurityConfigurerAdapter < /code> (я хочу избавиться от него позже, так как он устарел).
Итак, мой класс конфигурации выглядит так: < /p>

Код: Выделить всё

@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("spring_user")
.password("password123")
.roles("ADMIN");
}

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests((authz) -> authz.anyRequest().authenticated())
.httpBasic(Customizer.withDefaults());

return http.build();
}

@Bean
public static PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
< /code>
pom.xml файл: < /p>

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0

org.springframework.boot
spring-boot-starter-parent
3.0.1
 

com.codelib
basic-auth-security
0.0.1-SNAPSHOT
basic-auth-security
basic-auth-security

17



org.springframework.boot
spring-boot-starter-security


org.springframework.boot
spring-boot-starter-web


org.springframework.boot
spring-boot-devtools
runtime
true


org.springframework.boot
spring-boot-starter-test
test


org.springframework.security
spring-security-test
test


org.springframework.security
spring-security-config
5.7.3






org.springframework.boot
spring-boot-maven-plugin





Обратите внимание, что у меня есть Spring-boot-starter-web зависимость.
В остальной части проекта нет ничего интересного. Когда я пытаюсь запустить приложение, отображается следующее сообщение: < /p>
java: cannot access javax.servlet.Filter
class file for javax.servlet.Filter not found
< /code>
и идея перенаправляет меня в файл конфигурации. (Но никакие строки кода подчеркнуты красным)
Что может быть причиной этого?

Подробнее здесь: https://stackoverflow.com/questions/749 ... let-filter

Вернуться в «JAVA»