1. Description of the problem
In the spring project of idea, you often encounter Could not autowire. No beans of ' xxxx ' type found error hint. However, the compilation and operation of the program is not a problem, this error will not have an impact. But the red error hints are somewhat uncomfortable for some obsessive-compulsive programmers.
2. Causes
Spring Auto Scan configuration, in the case of editing, can not find the corresponding bean, and then prompted to find the corresponding bean error. Common in MyBatis Mapper, as follows:
<!--Mapper Scanner Configurer -<BeanID= "Mapperscannerconfig"class= "Org.mybatis.spring.mapper.MapperScannerConfigurer"> < Propertyname= "Basepackage"value= "Com.adu.spring_test.mybatis.dao" /> < Propertyname= "Sqlsessionfactorybeanname"value= "Sqlsessionfactory" /></Bean>
3. Solution
Reduce the level of autowired detection by changing the level of severity from previous error to warning or other levels that can be ignored.
Reference:
- Spring Annotated mode idea could not autowire,eclipse but no problem
IntelliJ idea cancels could not autowire. No beans of ' xxxx ' type found error hint