1.折腾了两天的springboot+springsecurity+mybatis+thymeleaf集成,参考博客如下
springboot+mybatis+SpringSecurity 实现用户角色数据库管理https://blog.csdn.net/u012373815/article/details/54633046
2.这篇博客写的很详细,在此感谢”双斜杠少年“博主,但是里边有一个小坑,提醒一下,就是mybatis的mapper. 文件命名必须和对应的dao一样,如文中UserDao.java对应的 文件应该命名为UserDao. ,不知为何作者写成了UserDaomapper.
3.在换成数据库方式读取用户信息时,此时一定要即可,数据库中用户的角色role一定要写成ROLE_ADMIN的形式,前边的ROLE_是必须得加的!!!
4.在.antMatchers(\"/manager/**\").hasRole(“ADMIN”),配置是,一定不能加ROLE_,因为springsecurity底层会自动去掉数据库中的ROLE_,如果在这里仍然加这个前缀,在启动时会报错如下:org.spring work.beans.factory.BeanCreationException: Error creating bean with name ‘springSecurityFilterChain’ defined in class path resource [org/spring work/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.spring work.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method ‘springSecurityFilterChain’ threw exception; nested exception is java.lang.IllegalArgumentException: role should not start with ‘ROLE_’ since it is automatically inserted. Got ‘ROLE_ADMIN’
继续阅读与本文标签相同的文章
这项技术可以合成以假乱真的奥巴马视频
家用光伏发电组件怎么清洗维护
-
淘集集经营模式变更:合伙人自营,主要供应商已成股东合伙人
2026-05-18栏目: 教程
-
88%中国员工相信AI超过经理 人见多了就更喜欢狗?
2026-05-18栏目: 教程
-
删库不要跑,我站起来还可以删
2026-05-18栏目: 教程
-
拼硬件真过时了?卡萨帝冰箱乌镇全讲场景
2026-05-18栏目: 教程
-
哈弗F7有AI更便捷 全球最流行的交互方式了解一下
2026-05-18栏目: 教程
