问题描述:

确定在实现类上使用了注解,@Repository,并且开启了扫描包,且类旁边出现了叶子,点击叶子,会跳到配置类,即应该是注入成功了,但是测试的时候一直报错   no bean named  xxxxx available。。。

 

可能的原因:

使用@Controller,@Service,@Repository等注解 ,将类注解之后,会有一个默认的bean id,就是

类名首字母小写。。。 测试的时候如果使用了类名就会报错。。。。

 

解决方法:

1.  @Repository("ReaderInfoMapperImpl")

指定名字

2. 不使用注解,使用<bean>来注入



<bean id="ReaderInfoMapper" class="com.zhx.mapper.ReaderInfoMapperImpl">
<property name="sqlSessionTemplate" ref="sqlSessionTemplate"/>
</bean>


 

 

总结:暂时不清楚底层原因。。。。




TRANSLATE with x



English



​Arabic​

​Hebrew​

​Polish​

​Bulgarian​

​Hindi​

​Portuguese​

​Catalan​

​Hmong Daw​

​Romanian​

​Chinese Simplified​

​Hungarian​

​Russian​

​Chinese Traditional​

​Indonesian​

​Slovak​

​Czech​

​Italian​

​Slovenian​

​Danish​

​Japanese​

​Spanish​

​Dutch​

​Klingon​

​Swedish​

​English​

​Korean​

​Thai​

​Estonian​

​Latvian​

​Turkish​

​Finnish​

​Lithuanian​

​Ukrainian​

​French​

​Malay​

​Urdu​

​German​

​Maltese​

​Vietnamese​

​Greek​

​Norwegian​

​Welsh​

​Haitian Creole​

​Persian​

 



 


TRANSLATE with



COPY THE URL BELOW



Back



EMBED THE SNIPPET BELOW IN YOUR SITE


Enable collaborative features and customize widget: ​​Bing Webmaster Portal​


Back