Org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying Bean of type [ Com.fkhd.whiteshirt.daos.UserMapper] found for dependency:expected at least 1 bean which qualifies as Autowire For this dependency. Dependency annotations: {@org. springframework.beans.factory.annotation.Autowired (Required=true)}
Spring-mybatis:
<!--spring and MyBatis are perfectly integrated and do not require mybatis configuration mapping files--> <bean id= "Sqlsessionfactory"
Org.mybatis.spring.SqlSessionFactoryBean ">
<property name=" DataSource "
ref=" Localdatasource "/>" <property name= "mapperlocations" value= "Classpath:mapper/*.xml" ></property>
</bean>
<!--the package name of the DAO interface, Spring automatically finds the class-->
<bean class= "Org.mybatis.spring.mapper.MapperScannerConfigurer" below it >
<property name= "basepackage" value= "Com.fkhd.whiteshirt.daos"/> <property name=
" Sqlsessionfactorybeanname "value=" sqlsessionfactory "></property>
</bean>
Serviceimpl:
@Autowired
private Usermapper usermapper;
Modify Serviceimpl to:
@Autowired (required=false)
private Usermapper usermapper;
No error, but usermapper null, also do not inject, so that the solution is not an error, but the project can not continue, so find another way.
All the solutions have been tried, not resolved, so they are looking back at their own projects.
My reason for the error in: Web.xml boot is not loaded soring-mybatis.xml, plus later problem solving.
My reason for this is that Web.xml is not loaded, just a problem. Can see if you are loading, if loaded to see other reasons!
Configurations that can be run:
Spring-mybatis (not modified):
<!--spring and MyBatis are perfectly integrated and do not require mybatis configuration mapping files--> <bean id= "Sqlsessionfactory"
Org.mybatis.spring.SqlSessionFactoryBean ">
<property name=" DataSource "
ref=" Localdatasource "/>" <property name= "mapperlocations" value= "Classpath:mapper/*.xml" ></property>
</bean>
<!--the package name of the DAO interface, Spring automatically finds the class-->
<bean class= "Org.mybatis.spring.mapper.MapperScannerConfigurer" below it >
<property name= "basepackage" value= "Com.fkhd.whiteshirt.daos"/> <property name=
" Sqlsessionfactorybeanname "value=" sqlsessionfactory "></property>
</bean>
Serviceimpl (not modified):
@Autowired
private Usermapper usermapper;