spring循環依賴解決,Springboot循環依賴解決


 

================================

©Copyright 蕃薯耀 2022-04-06

https://www.cnblogs.com/fanshuyao/

 

 

一、問題描述

 

Parameter 0 of method authorizationAttributeSourceAdvisor in org.apache.shiro.spring.boot.autoconfigure.ShiroAnnotationProcessorAutoConfiguration required a bean named 'authorizer' that could not be found.

***************************
APPLICATION FAILED TO START
***************************
 
Description:
 
Parameter 0 of method authorizationAttributeSourceAdvisor in org.apache.shiro.spring.boot.autoconfigure.ShiroAnnotationProcessorAutoConfiguration required a bean named 'authorizer' that could not be found.
 
 
Action:
 
Consider defining a bean named 'authorizer' in your configuration.

 

 

二、解決方案

增加DefaultWebSecurityManager配置

 
import javax.annotation.Resource;
 
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
@Configuration
public class ShiroConfig {
 
    @Resource
    private ShiroRealm shiroRealm;
    
    
    @Bean
    public DefaultWebSecurityManager defaultWebSecurityManager() {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        
        //shiro md5加密
        /*
        HashedCredentialsMatcher matcher = new HashedCredentialsMatcher();
        matcher.setHashAlgorithmName("md5");
        matcher.setHashIterations(2);
        
        shiroRealm.setCredentialsMatcher(matcher);
        */
        
        defaultWebSecurityManager.setRealm(shiroRealm);
        return defaultWebSecurityManager;
    }
}

 

 

(時間寶貴,分享不易,捐贈回饋,^_^)

 

================================

©Copyright 蕃薯耀 2022-04-06

https://www.cnblogs.com/fanshuyao/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM