Springboot + Mybatis-plus,集成shiro,启动报错:

 No bean of type 'org.apache.shiro.realm.Realm' found. 
Please create bean of type 'Realm' or add a shiro.ini in the root classpath (src/main/resources/shiro.ini) or in the META-INF folder (src/main/resources/META-INF/shiro.ini).

解决方案:pom.xml右键-->maven-->reload project ;maven-->clean重新加载项目

原因分析:在启动"securityManager"这个bean时,依赖于ShiroRealm这个bean

@Bean("securityManager")
	public DefaultWebSecurityManager securityManager(ShiroRealm myRealm) {
		DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
        //设置ream
		securityManager.setRealm(myRealm);

    ......
}

在工程启动时,打开info级别的日志,会有 No MyBatis mapper was found in ‘[x.x.demo]’ package. Please check your configuration 警告,应该是springboot未扫描到响应的bean,导致bean找不到,至于为什么reload project可以解决,就很玄学了......

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐