ShiroAnnotationProcessorAutoConfiguration required a bean named ‘authorizer‘ that could not be found

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

©Copyright 蕃薯耀 2022-04-06

​蕃薯耀的博客_CSDN博客

一、问题描述

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

​​​​​​​蕃薯耀的博客_CSDN博客

猜你喜欢

转载自blog.csdn.net/w995223851/article/details/123983515