美文网首页java
Consider defining a bean named '

Consider defining a bean named '

作者: 星钻首席小管家 | 来源:发表于2020-08-07 09:10 被阅读0次

SpringBoot整合Shiro时出错

转自:https://blog.csdn.net/qq_33655674/article/details/83585584

错误:

2018-10-31 15:49:38.697 ERROR --- [restartedMain] o.s.b.d.LoggingFailureAnalysisReporter: 

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method authorizationAttributeSourceAdvisor in com.csair.etm.manage.configuration.ShiroConfiguration required a bean named 'authenticator' that could not be found.


Action:

Consider defining a bean named 'authenticator' in your configuration.
<!--之前用的依赖-->
<!--Shiro-->
<dependency>
     <groupId>org.apache.shiro</groupId>
     <artifactId>shiro-spring</artifactId>
     <version>1.4.0</version>
 </dependency>
 <!--上面这样没报错,换成下面的依赖就报错了-->
 <!--shiro-->
 <dependency>
     <groupId>org.apache.shiro</groupId>
     <artifactId>shiro-spring-boot-web-starter</artifactId>
     <version>1.4.0</version>
 </dependency>

原因:
在starter的org.apache.shiro.spring.config.web.autoconfigure类已经定义了securityManager,代码如下:

@Bean
   @ConditionalOnMissingBean
   protected SessionsSecurityManager securityManager(List<Realm> realms) {
       return super.securityManager(realms);
   }

所以把注入的securityManager类型换成SessionSecurityManager就可以了

相关文章

网友评论

    本文标题:Consider defining a bean named '

    本文链接:https://www.haomeiwen.com/subject/aggxdktx.html