Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring安全性:配置(AuthenticationManagerBuilder身份验证)_Spring_Spring Security_H2 - Fatal编程技术网

Spring安全性:配置(AuthenticationManagerBuilder身份验证)

Spring安全性:配置(AuthenticationManagerBuilder身份验证),spring,spring-security,h2,Spring,Spring Security,H2,我有一个具有属性的实体用户: id 用户名 密码 firstname lastname userrole select username, password, enabled from users where username = ? 属性userrole是enum和noSet的类型,因此为1个userrole/user 现在我想做一个JDBC身份验证 目前我有: auth .jdbcAuthentication() .dataSource(dataSource)

我有一个具有属性的实体
用户

  • id
  • 用户名
  • 密码
  • firstname
  • lastname
  • userrole
select username, password, enabled from users where username = ?
属性
userrole
enum
和no
Set
的类型,因此为1个userrole/user

现在我想做一个JDBC身份验证

目前我有:

auth
    .jdbcAuthentication()
        .dataSource(dataSource)
        .usersByUsernameQuery("select username, password from user where username=?")
        .authoritiesByUsernameQuery("select username, userrole from user where username=?");
但这不起作用

如何在
.usersByUsernameQuery(“…”)和
.authorities ByUsernameQuery(“…”)中进行查询如何制定

错误消息:

原因:org.h2.jdbc.JdbcSQLException:参数“columnIndex”不允许值“3” 参数“columnIndex”[90008-192]的值“3”无效 在org.h2.message.DbException.getJdbcSQLException(DbException.java:345)~[h2-1.4.192.jar:1.4.192] 在org.h2.message.DbException.get(DbException.java:179)~[h2-1.4.192.jar:1.4.192] 在org.h2.message.DbException.getInvalidValueException(DbException.java:228)~[h2-1.4.192.jar:1.4.192] 在org.h2.jdbc.jdbcsresultset.checkColumnIndex(jdbcsresultset.java:3172)~[h2-1.4.192.jar:1.4.192] 在org.h2.jdbc.jdbcsresultset.get(jdbcsresultset.java:3200)~[h2-1.4.192.jar:1.4.192] 在org.h2.jdbc.jdbcsresultset.getBoolean(jdbcsresultset.java:541)~[h2-1.4.192.jar:1.4.192] 在org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl$1.mapRow(JdbcDaoImpl.java:223)~[spring-security-core-4.1.3.RELEASE.jar:4.1.3.RELEASE] 在org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl$1.mapRow(JdbcDaoImpl.java:218)~[spring-security-core-4.1.3.RELEASE.jar:4.1.3.RELEASE] 位于org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93)~[spring-jdbc-4.3.3.RELEASE.jar:4.3.3.RELEASE] 位于org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60)~[spring-jdbc-4.3.3.RELEASE.jar:4.3.3.RELEASE] 在org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:697)~[spring-jdbc-4.3.3.RELEASE.jar:4.3.3.RELEASE] 在org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633)~[spring-jdbc-4.3.3.RELEASE.jar:4.3.3.RELEASE] ... 省略65个公共框架


用户的查询需要3个参数,请参见:

  • 用户按用户名查询一条SQL语句,用于查询给定用户名的用户名、密码和启用状态。默认值是
select username, password, enabled from users where username = ?