Я пытался научиться весенней безопасности. Следующий код взят из Spring.io , и я использовал один и тот же файл pom.xml
и версию с загрузочной пружиной.
package com.demo.hello;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/home").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
@Bean
@Override
public UserDetailsService userDetailsService() {
UserDetails user =
User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER")
.build();
return new InMemoryUserDetailsManager(user);
}
}
Тем не менее я получаю следующую ошибку в методе configure
The type org.springframework.security.web.authentication.UsernamePassw
ordAuthenticationFilter cannot be resolved. It is indirectly
referenced from required .class files
Ошибка не появляется, когда я использую spring-boot-1.5.14, но она не работает с использованием Spring-boot-2.0.3 и Spring.io . Версия 2.0.3.
Я не могу понять, что происходит