Transfer from https://blog.csdn.net/u012453…
Original blog delete this record
1. Problem description
In idea’s spring project, we often encounter court not autowire No beans of ‘XXXX’ type found. However, there is no problem with the compilation and operation of the program, and this error prompt will not have an impact. But the red error prompt is more or less uncomfortable in the eyes of some OCD programmers.
-
reason
There may be two reasons. The first is the problem of IntelliJ idea's own tools. The second is caused by the import package error when we import the @ service package
The first reason is the spring auto scan configuration. When editing, the corresponding bean cannot be found, so the error that the corresponding bean cannot be found is prompted. Common mappers in mybatis are as follows:
<!– mapper scanner configurer –>
<bean id=”mapperScannerConfig” class=”org.mybatis.spring.mapper.MapperScannerConfigurer”>
<property name="basePackage" value="com.adu.spring_test.mybatis.dao" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
- Solution
For the first reason, the solution is to reduce the level of Autowired detection and change the level of severity from the previous error to warning or other negligible levels.
For the second reason, the solution is of course to import the correct package. First, let's take a look at the error packages that are easiest to import, as shown below:
import com.alibaba.dubbo.config.annotation.Service;
The correct package should be the following
import org.springframework.stereotype.Service;
Remember!!!!