首先我参考文章:https://blog.csdn.net/Yearingforthefuture/article/details/117384035
进行学习,由于此文章没有讲springboot的版本, 我于是用了idea2022.3.1的默认方法创建了一个springboot的项目,默认版本是3.0.2
第一步进行整合的时候就出现问题
在登录的时候,报UnavailableSecurityManagerException异常
通过增加ThreadContext.bind(securityManager);解决
// 安全管理器对象创建
@Bean
public SecurityManager securityManager(EmployeeRealm employeeRealm) {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm(employeeRealm);
ThreadContext.bind(securityManager);
return securityManager;
}
shiro的拦截失效,网上文章看了很多没找到问题,通过打断点
PathMatchingFilterChainResolver文件的getChain, 发现断点根本就不到
最后通过修改springboot的版本号得以解决,我之前用的是springboot 3.0.2, 修改成 springboot 2.1.1.RELEASE 之后得以解决,不知道其他版本还有没有问题,由于修改版本所需要的时间比较长,还没有尝试。
先继续往后面学习吧,学完了再来尝试其他的版本