org.postgresql.util.PSQLException:列索引超出范围:3,列数:2

我决定通过使用spring security和database添加身份validation来修改我的应用程序。 在我使用XML中的userpassword进行普通身份validation之前。 它工作正常。

我的authentication-manager看起来像这样

      

但是,当我尝试进行身份validation时,我有exception

 org.springframework.security.authentication.InternalAuthenticationServiceException: PreparedStatementCallback; SQL [select u sername, password from pmc.username_password where username=?;]; The column index is out of range: 3, number of columns: 2.; nested exception is org.postgresql.util.PSQLException: The column index is out of range: 3, number of columns: 2. 

我在XML文件中的sql语法有什么问题?

Spring Security要求用户查询三列,依次为:

  1. 用户名
  2. 密码
  3. enabled(布尔值)

你没有最后一个。 如果数据库中没有等效的“启用”,则可以使用TRUE常量。