【J】BeanCreationException: Error creating bean with name 'shiroFilter' defined in class path resource

在做SSM博客系统的时候遇到以下报错:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in class path resource [applicationContext.xml

shiro有问题,所有的dao有问题

开始的时候以为是shiro的realm有问题,后来一步步排查,发现InitComponent类( implements ApplicationContextAware,用于项目启动时将一些信息保存到ApplicationContex中共享,如用户信息等)的setApplicationContext没有执行而直接执行了contextInitialized方法【也就是下图第一个断点未执行,直接跳到第二个断点】applicationContext为null,自然不能调用applicationContext.getBean()方法。

set方法未执行
至于为何未执行,经过排除法(一步步删除写好的代码),发现是:
一个mapper的某个方法的resultMap写成了resultType

这个问题我用了12个小时才解决,至于为什么报这个错误?明明shiro的realm中用的bean blogger与出错的mapper对应的bean blogType没有直接关系。
估计后期学习ApplicationContextAware接口的原理才能真正理解

部分报错信息:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in class path resource [applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor#0' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'myRealm' while setting bean property 'realm'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myRealm': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.yblog.service.BloggerService com.yblog.realm.MyRealm.bloggerService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bloggerService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.yblog.dao.BloggerDao com.yblog.service.impl.BloggerServiceImpl.bloggerDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.yblog.dao.BloggerDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Related cause: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'shiroFilter': Requested bean is currently in creation: Is there an unresolvable circular reference?
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blogDao' defined in file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\dao\BlogDao.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\mappers\BlogMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'blogResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: blogResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bloggerDao' defined in file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\dao\BloggerDao.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\mappers\BlogMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'blogResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: blogResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blogTypeDao' defined in file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\dao\BlogTypeDao.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\mappers\BlogMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'blogResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: blogResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commentDao' defined in file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\dao\CommentDao.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\mappers\BlogMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'blogResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: blogResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'linkDao' defined in file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\dao\LinkDao.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\mappers\BlogMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'blogResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: blogResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blogDao' defined in file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\dao\BlogDao.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\mappers\BlogMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'blogResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: blogResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bloggerDao' defined in file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\dao\BloggerDao.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\apache-tomcat-8.5.31-windows-64位\apache-tomcat-8.5.31\webapps\YBlog_war\WEB-INF\classes\com\yblog\mappers\BlogMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'blogResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: blogResultMap
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值