shiro整合redis出现java.lang.ClassNotFoundException: org.apache.shiro.event.EventBus异常

时间:2024-03-30 22:39:11

Maven依赖如下

shiro整合redis出现java.lang.ClassNotFoundException: org.apache.shiro.event.EventBus异常

异常信息如下

java.lang.IllegalStateException: Error processing condition on org.apache.shiro.spring.boot.autoconfigure.ShiroBeanAutoConfiguration.eventBus

Caused by: java.lang.IllegalStateException: @ConditionalOnMissingBean did not specify a bean using type, name or annotation and the attempt to deduce the bean's type failed

Caused by: org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanTypeDeductionException: Failed to deduce bean type for org.apache.shiro.spring.boot.autoconfigure.ShiroBeanAutoConfiguration.eventBus

Caused by: java.lang.ClassNotFoundException: org.apache.shiro.event.EventBus

从ClassNotFoundException这个异常可以看出,肯定是Maven依赖的jar包中缺少了EventBus这个class文件。于是百度了一波发现org.apache.shiro.event.EventBus是shiro-core1.3以上提供的。然后我搜索了一下maven工程下依赖的shiro-core

shiro整合redis出现java.lang.ClassNotFoundException: org.apache.shiro.event.EventBus异常

原来我的maven工程中已经依赖了shiro-core1.4.0的版本,由于引进了shiro-redis3.1.0的整合jar包内部也依赖了一个shiro-core,但是版本是1.2.6的,且把之前引入的shiro-core1.4.0的jar包剔除出去了。

既然是jar包依赖的问题那就好解决了,在shiro-redis中剔除掉shiro-core的jar包即可。果然再次运行后,不再报错。

shiro整合redis出现java.lang.ClassNotFoundException: org.apache.shiro.event.EventBus异常