@Configuration @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .anyRequest() .authenticated() .and() //开启默认登录页面 .formLogin() //默认登录页面 .loginPage("/login") //默认登录成功跳转页面 .defaultSuccessUrl("/chat") .permitAll() .and() //设置注销 .logout() .permitAll(); } @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication() .passwordEncoder(passwordEncoder()) .withUser("qin").password(passwordEncoder().encode("111")).roles("USER") .and() .withUser("kai").password(passwordEncoder().encode("222")).roles("USER"); } }
There is no PasswordEncoder mapped for the id "null"
最新推荐文章于 2024-07-15 17:19:02 发布