今天在springboot整合shiro的时候遇到了一些问题记录一下
1.第一个错误
编辑
报错内容
Cause: org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton. This is an invalid application configuration.
查阅资料才知道看报错是 ThreadContext未绑定SecurityManager
我看自己代码也没写
给他加上
ThreadContext.bind(defaultWebSecurityManager);
加上之后运行又出现第二个错误
第二个错误
编辑
报错内容
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed: java.lang.NoClassDefFoundError: javax/servlet/ServletRequest] with root cause
后面也是查了资料才确定是少了javax.servlet依赖
pom.xml文件导入以下依赖
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
然后重新运行,方法正常调用
运行正常,密码是错的没错。页面也正常
我jdk是17版本的
完结~~~