我正在嘗試在 Spring Boot 中使用 JDBC 身份驗證。我正在嘗試使用與默認“用戶”不同的表。但是用這個方法@Overrideprotected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication().dataSource(dataSource) .usersByUsernameQuery("SELECT email as USERNAME, PASSWORD as password FROM [user_account] WHERE email=?");}使用給定的表架構:[![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.如何使用我自己的用戶數據表進行 JDBC 身份驗證?
1 回答

慕斯王
TA貢獻1864條經驗 獲得超2個贊
您可以通過附加啟用作為要選擇的第三個參數來更新您的查詢嗎
SELECT email as USERNAME, PASSWORD as password, enabled FROM [user_account] WHERE email=?
添加回答
舉報
0/150
提交
取消