maven所需要的依赖上章已经说过这章不做解释
所谓的内存用户就是将用户账号密码写死在代码中,这种方法适合刚接触security的同学,毕竟学习是需要徐徐渐进的嚒。
好了话不多说直接撸代码
1.新建WebSecurityConfig.java 并继承WebSecurityConfigurerAdapter类
代码如下
package com.hutian.security.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
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