在用spring security对用户进行安全认证的时候,碰到一个很头疼的问题,spring security是使用其默认数据库表结构的,默认表为users,其实嫌麻烦的话,直接使用这个默认配置也是可以的,但是我的项目里已经有了表结构规范,这个时候就需要改变其默认的表结构,以下为securityConfig.java的代码,通过覆盖JdbcDaoImpl中的usersByUsernameQuery和authoritiesByUsernameQuery的sql语句更改默认的用户表users:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.confi