【J】BeanCreationException: Error creating bean with name 'shiroFilter' defined in class path resource
程序员文章站
2022-05-19 10:01:29
...
在做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()方法。
至于为何未执行,经过排除法(一步步删除写好的代码),发现是:
一个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
上一篇: linux下yum为php安装gd库
推荐阅读
-
Error creating bean with name 'entityManagerFactory' defined in class path resource解决方案
-
Spring Boot 报错:Error creating bean with name 'entityManagerFactory' defined in class path resource
-
Error creating bean with name 'entityManagerFactory' defined in class path resource解决方案
-
Error creating bean with name 'sqlSessionFactory' defined in class path resource [config/spring/applicationContext.xml]: Invocation of init me
-
Spring Cloud中遇到的Error creating bean with name 'hystrixCommandAspect' defined in class path resource
-
【SpringBoot】----- Error creating bean with name 'entityManagerFactory' defined in class path resourc
-
error creating bean with name sqlSessionFactory defined in class path resource spring/spring-mvc
-
Error creating bean with name 'entityManagerFactory' defined in class path resource解决方案
-
遇到Error creating bean with name 'flywayInitializer' defined in class path resource解决办法
-
【J】BeanCreationException: Error creating bean with name 'shiroFilter' defined in class path resource