我在 app-config.xml 中配置了以下内容:
<security:http auto-config="true" />
<security:global-method-security secured-annotations="enabled" />
<security:authentication-manager>
<security:authentication-provider>
<security:jdbc-user-service data-source-ref="dataSource"
users-by-username-query="
select login, password
from accounts where login=? and password=?"
authorities-by-username-query="
select a.login, ar.authority from accounts a, account_roles ar
where a.account_id = ar.account_id and a.login =? "
/>
</security:authentication-provider>
</security:authentication-manager>
但是,当我启动我的应用程序时,它会显示登录信息,我收到以下错误消息:
原因:PreparedStatementCallback;未分类 SQLException for SQL [select login, > password from accounts where login=? 和密码=?]; SQL 状态 [90012];错误代码 [90012];未设置参数“#2”;SQL 语句:select login, password from accounts where login=? 和密码=?[90012-170];嵌套异常是 org.h2.jdbc.JdbcSQLException:未设置参数“#2”;SQL 语句:select login, password from accounts where login=? 和密码=?[90012-170]
有什么想法有什么问题吗?
我不完全确定 security:jdbc-user-service 是如何工作的?它如何填写我的选择查询中的=?
我的数据库定义为:
CREATE TABLE accounts (
account_id VARCHAR NOT NULL,
login VARCHAR NOT NULL,
password VARCHAR NOT NULL,
PRIMARY KEY (account_id)
);
CREATE TABLE account_roles (
account_id VARCHAR NOT NULL,
authority VARCHAR NOT NULL,
PRIMARY KEY (account_id),
CONSTRAINT FK_account_roles FOREIGN KEY (account_id) REFERENCES accounts (account_id)
);
谢谢