SpringBoot+MyBatis时报错org.springframework.beans.factory.UnsatisfiedDependencyException: Error creatin

本文介绍了在SpringBoot+MyBatis项目中遇到的报错问题,错误信息涉及到Bean创建失败,主要是由于Mapper XML解析错误,无法找到类型别名'res1'所导致。解决方案可能涉及检查XML映射文件中的类路径和类型别名配置。
摘要由CSDN通过智能技术生成

今天一个朋友写项目SpringBoot+MyBatis报错如下,我们找到一些关键字,就可以确定错误大致在什么地方啦,不难看出是xml出错啦,去xml看看是不是那个细节出错啦

在这里插入图片描述
下面我标记的地方应该使用parameterMap,因为是多表连接查询返回的结果
在这里插入图片描述

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2020-04-30 16:46:40.795 ERROR 7760 — [ restartedMain] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘moduleController’: Unsatisfied dependency expressed through field ‘moduleService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘moduleServiceImp’: Unsatisfied dependency expressed through field ‘moduleDao’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘moduleDao’ defined in file [D:\win8\sts\stsworke\power\target\classes\com\zsc\dao\ModuleDao.class]: Unsatisfied dependency expressed through bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method ‘sqlSessionFactory’ threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [D:\win8\sts\stsworke\power\target\classes\mapper\RoleAndModuleDaomapper.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 ‘res1’. Cause: java.lang.ClassNotFoundException: Cannot find class: res1
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor A u t o w i r e d F i e l d E l e m e n t . i n j e c t ( A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r . j a v a : 586 )   [ s p r i n g − b e a n s − 5.0.8. R E L E A S E . j a r : 5.0.8. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . a n n o t a t i o n . I n j e c t i o n M e t a d a t a . i n j e c t ( I n j e c t i o n M e t a d a t a . j a v a : 91 )   [ s p r i n g − b e a n s − 5.0.8. R E L E A S E . j a r : 5.0.8. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . a n n o t a t i o n . A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r . p o s t P r o c e s s P r o p e r t y V a l u e s ( A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r . j a v a : 372 )   [ s p r i n g − b e a n s − 5.0.8. R E L E A S E . j a r : 5.0.8. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . p o p u l a t e B e a n ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 1341 )   [ s p r i n g − b e a n s − 5.0.8. R E L E A S E . j a r : 5.0.8. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . d o C r e a t e B e a n ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 572 )   [ s p r i n g − b e a n s − 5.0.8. R E L E A S E . j a r : 5.0.8. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . c r e a t e B e a n ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 495 )   [ s p r i n g − b e a n s − 5.0.8. R E L E A S E . j a r : 5.0.8. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . l a m b d a AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) [springbeans5.0.8.RELEASE.jar:5.0.8.RELEASE]atorg.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) [springbeans5.0.8.RELEASE.jar:5.0.8.RELEASE]atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372) [springbeans5.0.8.RELEASE.jar:5.0.8.RELEASE]atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341) [springbeans

回答: 根据你提供的引用内容,出现这个错误是因为Spring应用程序上下文启动失败,具体的错误信息是`org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentationPluginsBootstrapper'`。中给出了解决方法,可能是因为在依赖中同引入了MybatisMybatis-plus,导致冲突。你可以尝试解决冲突,选择其中一个依赖来使用。同,还要检查父模块是否已经引入了Mybatis依赖,而后在本模块又引入了Mybatis-plus模块,这种情况也可能会导致冲突。希望这些信息对你有帮助。123 #### 引用[.reference_title] - *1* [springBoot 启动之后报错Unsatisfied dependency expressed through field ‘baseMapper’](https://blog.csdn.net/borderhz/article/details/117173034)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *2* *3* [org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean](https://blog.csdn.net/Faker_News/article/details/111710850)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值