springboot整合shiro安全框架异常记录
异常显示:
[ERROR] - org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup
(TomcatStarter.java:61)
- Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message:
- Error creating bean with name 'filterShiroFilterRegistrationBean' defined in class path resource
- [org/apache/shiro/spring/config/web/autoconfigure/ShiroWebFilterConfiguration.class] ```
Description:
Method filterShiroFilterRegistrationBean in org.apache.shiro.spring.config.web.autoconfigure.ShiroWebFilterConfiguration
required a bean named 'shiroFilterFactoryBean' that could not be found.
创建bean异常,百度了很久,不是注解问题。
万般无奈之下,想到会不会是依赖问题。不说了先看看项目导入的依赖(MavenRepository官网):
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring-boot-web-starter</artifactId>
<version>1.5.3</version>
</dependency>
然后点进去看看它到底有那些依赖,
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
这都是啥玩意,然后就只能,,,换!
去官网把前四个依赖全放进去了,刷新,运行。OK了,OK了,OK了,,,
瞬间想骂自己,用户使用的最多的四个不用。然后我就去研究研究,目前发现Shiro整合Spring是包含前两个依赖的。
然后就该思考为什么呢?
行吧,我也整不出来,初步怀疑,shiro整合springboot中的:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
依赖导致的(自我怀疑)
此博客只是记录本人遇到的此异常的解决方案,上述问题若有大佬讲解,万分感激!