shiro造成dubbo无法注入java.lang.IllegalStateException: ApplicationEventMulticaster not initialized

xiaoxiao2021-02-27  313

1在使用shiro和dubbo的时候,启动项目报如下相关异常信息

2启动项目加载web.xml时会加载

<context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:applicationContext.xml </param-value> </context-param>3applicationContext.xml引入了shiro和dubbo的配置

<!-- 引入所需配置文件 --> <import resource="classpath*:spring/dubbo.xml" /> <import resource="classpath*:spring/redis.xml" /> <import resource="classpath*:spring/session.xml" /> <import resource="classpath*:spring/shiro.xml" />4shiro.xml中配置了shirofilter,securitymanager,realm等

5跟了一下shirofilter的源码发现

6dubbo是注入了bean,而shiro拦截了所有的bean的注入,交给SecurityManager;

7初始化shiro判断bean是否实现了filter,判断dubbo是否注入了相关的service,最后就会出现shiro造成dubbo无法注入的现象。

8解决办法,在初始化application.xml时,加上如下配置。

<!-- shiro会造成dubbo的服务无法注入,所以相关service通过配置文件解决 --> <dubbo:reference id="xxService" interface="com.xxx.xxx.sys.service.xxService" check="false" /> <dubbo:reference id="xxService" interface="com.xxx.xxx.sys.service.xxService" check="false" />9源码太深奥,以上只是个人见解和解决办法,

转载请注明原文地址: https://www.6miu.com/read-4743.html

最新回复(0)