Tag Archives: no bean named xxxxx available

Error: no bean named xxxxx available [How to Solve]

Problem Description:

Make sure that the annotation @repository is used on the implementation class, and the scanning package is enabled, and a leaf appears next to the class. Click the leaf to jump to the configuration class, that is, the injection should be successful, but an error is always reported during the test no bean named xxxxx available…

Possible causes:

Using @controller, @service, @repository and other annotations, after class annotation, there will be a default bean ID, which is

Class name initial lowercase… If the class name is used during the test, an error will be reported….

Solution:

1. @Repository(“ReaderInfoMapperImpl”)

Specify name

2. Do not use annotation, use < bean> To inject

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