在 Spring 引导中进行 JDBC 身份验证时,是否必须使用默认的 'users' table?

When making JDBC Authentication in Spring Boot, do I have to use the default 'users' table?

我正在尝试在 Spring Boot 中使用 JDBC 身份验证。我正在尝试使用与默认 'users' 不同的 table。但是用这个方法

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.jdbcAuthentication().dataSource(dataSource)
        .usersByUsernameQuery("SELECT email as USERNAME, PASSWORD as password FROM [user_account] WHERE email=?");
}

使用给定的 table 架构: [![f][1]][1]

我收到以下错误:

17:34:29.800 [http-nio-8081-exec-1] INFO  o.s.j.support.SQLErrorCodesFactory - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]
17:34:29.806 [http-nio-8081-exec-1] WARN  o.s.s.o.p.endpoint.TokenEndpoint - Handling error: [![enter image description here][2]][2]InternalAuthenticationServiceException, PreparedStatementCallback; SQL [SELECT email as USERNAME, PASSWORD as password FROM [user_account] WHERE email=?]; The index 3 is out of range.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The index 3 is out of range.

如何使用我自己的用户数据 table 进行 JDBC 身份验证?

您可以通过将 enabled 作为第三个参数附加到 select

来更新您的查询吗

SELECT email as USERNAME, PASSWORD as password, enabled FROM [user_account] WHERE email=?