ssm整合时出错:Error creating bean with name ‘studentServiceImpl‘: Unsatisfied dependency expressed throug

本文档详细记录了一次在整合Spring、SpringMVC和MyBatis(SSM)时遇到的错误:Error creating bean with name 'studentServiceImpl'。错误源于在Spring配置文件和MyBatis映射文件中重复定义了同一DAO。解决方案是删除一处重复的配置。
摘要由CSDN通过智能技术生成

错误信息:

org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name ‘studentServiceImpl’: Unsatisfied
dependency expressed through field ‘studentDao’; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name ‘studentDao’ defined in file
[E:\develop\SpringMVC\springmvc-ssm整合\target\springmvc-ssm\WEB-INF\classes\com\caohanlin\dao\StudentDao.class]:
Unsatisfied dependency expressed through bean property
‘sqlSessionFactory’; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name ‘sqlSessionFactoryBean’ defined in class path
resource [conf/applicationContext.xml]: Invocation of init method
failed; nested exception is
org.springframework.core.NestedIOException: Failed to parse mapping
resource: ‘file
[E:\develop\SpringMVC\springmvc-ssm整合\target\springmvc-ssm\WEB-INF\classes\com\caohanlin\dao\StudentDao.xml]’;
nested exception is org.apache.ibatis.builder.BuilderException: Error
parsing Mapper XML. The XML location is ‘file
[E:\develop\SpringMVC\springmvc-ssm整合\target\springmvc-ssm\WEB-INF\classes\com\caohanlin\dao\StudentDao.xml]’.
Cause: java.lang.IllegalArgumentException: Mapped Statements
collection already contains value for
com.caohanlin.dao.StudentDao.insertStudent. please check
com/caohanlin/dao/StudentDao.xml and file
[E:\develop\SpringMVC\springmvc-ssm整合\target\springmvc-ssm\WEB-INF\classes\com\caohanlin\dao\StudentDao.xml]
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 : 643 ) 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 : 130 ) 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 i 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 : 399 ) 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 : 1422 ) 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 : 594 ) 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 : 517 ) 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:643) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)atorg.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)atorg.springframework.beans.factory.support.AbstractBeanFactory.lambdadoGetBean 0 ( A b s t r a c t B e a n F a c t o r y . j a v a : 323 ) 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 . D e f a u l t S i n g l e t o n B e a n R e g i s t r y . g e t S i n g l e t o n ( D e f a u l t S i n g l e t o n B e a n R e g i s t r y . j a v a : 222 ) 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 . d o G e t B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 321 ) 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 . g e t B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 202 ) 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 . D e f a u l t L i s t a b l e B e a n F a c t o r y . p r e I n s t a n t i a t e S i n g l e t o n s ( D e f a u l t L i s t a b l e B e a n F a c t o r y . j a v a : 882 ) a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . A b s t r a c t A p p l i c a t i o n C o n t e x t . f i n i s h B e a n F a c t o r y I n i t i a l i z a t i o n ( A b s t r a c t A p p l i c a t i o n C o n t e x t . j a v a : 878 ) a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . A b s t r a c t A p p l i c a t i o n C o n t e x t . r e f r e s h ( A b s t r a c t

BeanCreationException是Spring框架中的一个异常,表示在创建Bean出现了错误。该异常通常包含详细的错误信息,能够帮助我们找到问题所在。在你提供的引用中,有两个例子都涉及到了BeanCreationException异常。 引用中的BeanCreationException是在创建名为'transactionManager'的bean发生的错误,错误信息中提到文件路径[F:\IdeaProjects\ssmDemo1\out\artifacts\ssmDemo1_war_exp]。根据这些信息,我们可以初步判断问题可能是文件路径或配置的错误导致的。 引用中的BeanCreationException是在配置Redis的候发生的错误,错误信息中提到无法配置Redis的keyspace notifications。根据错误信息提供的链接,我们可以点击链接查看更详细的解决方法。 综上所述,BeanCreationException是在创建Bean出现的错误,在你提供的例子中有两个不同的情况。一个是文件路径或配置的错误,另一个是配置Redis的错误。具体解决方法需要根据具体的错误信息和配置来确定。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ssmDemo1:SSM框架整合练习项目 来自《2017-7黑马49期web》](https://download.csdn.net/download/weixin_42097914/18258169)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer'](https://blog.csdn.net/oDianZi1234567/article/details/103774172)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小林Code

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值