基于这个例子,我尝试在我的应用程序中实现Spring Security 。然而,我不能登录,只有当我注册,它做自动登录。当我想在注销后登录时,示例应用程序执行以下语句:
Hibernate: select user0_.id as id1_1_, user0_.email as email2_1_,
user0_.password as password3_1_, user0_.username as username4_1_
from user user0_ where user0_.username=?
Hibernate: select roles0_.users_id as users_id1_2_0_,
roles0_.roles_id as roles_id2_2_0_, role1_.id as id1_0_1_,
role1_.name as name2_0_1_
from user_roles roles0_ inner join role role1_ on roles0_.roles_id=role1_.id
where roles0_.users_id=?
另一方面,我的应用程序只执行以下语句:
Hibernate: select user0_.id as id1_1_, user0_.email as email2_1_,
user0_.password as password3_1_, user0_.username as username4_1_
from user user0_ where user0_.username=?
那里少了些什么,我想不出是什么。
2条答案
按热度按时间6jjcrrmo1#
不仅没有加载角色,而且找不到用户。因为
UserDetailsServiceImpl.loadUserByUsername
获取空用户名。在
login.html
更改:分为:
yh2wf1be2#
将“@joincolumn(name=”col\u name“)”添加到拥有众多Map的位置。