我正在尝试在Spring启动应用程序中使用spring security。我有以下方法来验证用户:
@Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication()
.dataSource(dataSource)
.passwordEncoder(bCryptPasswordEncoder)
.usersByUsernameQuery("select username,password from user where username=?")
.authoritiesByUsernameQuery("SELECT username,sys_role "
+ " FROM user join user_sys_role on user.id=user_sys_role.user_id"
+ " where username=?");
}
但是当我向它发送post
请求时它失败了,当我调试应用程序时它会提供错误:
org.springframework.security.authentication.InternalAuthenticationServiceException: PreparedStatementCallback; SQL [select username,password from user where username=?]; Column Index out of range, 3 > 2. ; nested exception is java.sql.SQLException: Column Index out of range, 3 > 2.
我该如何解决?
似乎,
中存在问题 .usersByUsernameQuery("select username,password from user where username=?")