IDEA下Spring项目报错-could not autowire. no beans of“” type found
2017-06-12 00:29
1171 查看
把一个eclipse的项目导入到IDEA,发现项目打开就报错:-could not autowire. no beans of“” type found。
在eclipse下面没有问题
项目编译和运行没有问题。
spring auto scan配置,在编辑情况下,无法找不到对应的bean,于是提示找不到对应bean的错误。常见于mybatis的mapper,如下:
也就是说,在项目没有运行的时候,无法自动扫描到相应的beans,IDEA就会认为这是一个错误,其实并没有什么影响。
找到如图所示的设置(File – Settings – Inspections),修改成 no highlighting,only fixed.保存,就不会再报错了。
在eclipse下面没有问题
项目编译和运行没有问题。
原因
网上搜索了一下原因。spring auto scan配置,在编辑情况下,无法找不到对应的bean,于是提示找不到对应bean的错误。常见于mybatis的mapper,如下:
<!-- 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>
也就是说,在项目没有运行的时候,无法自动扫描到相应的beans,IDEA就会认为这是一个错误,其实并没有什么影响。
解决
在IDEA的配置中设置这个检查项为: no highlighting,only fixed.看不到就好了=,=找到如图所示的设置(File – Settings – Inspections),修改成 no highlighting,only fixed.保存,就不会再报错了。
相关文章推荐
- IntelliJ idea在Spring配置无错误时,装配对象出现 Could not autowire. no beans of "XXX" type found
- Idea的spring工程里,经常会遇到Could not autowire. No beans of 'xxxx' type found的错误提示
- mybatis+spring boot, mapper 提示Could not autowire. No beans of … type found
- mybatis+spring boot, @Autowired 提示Could not autowire. No beans of … type found
- idea中mybatis+spring boot, mapper 提示Could not autowire. No beans of … type found解决办法
- 解决 IntelliJ IDEA Could not autowire. No beans of 'xxxx' type found 问题
- idea 出现Could not autowire. No beans of 'xxxxMapper' type found. 安装 Mybatis Plugin 插件
- Idea 注解错误could not autowire no beans of...plicationEventMulticaster not initialized
- 【问题】Could not autowire. No beans of … type found
- IDEA引入dao接口,Could not autowire. No beans of 'UserMapper' type found
- Could not autowire. No beans of … type found
- Could not autowire. No beans of 'UserMapper' type found.
- IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示
- could not autowire.No beans of 'FunctionService' type found.
- Could not autowire. No beans of 'xxxx' type found
- IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示
- Could not autowire. No beans of 'xxxMapper' type found.
- Could not autowire. No beans of 'xxxx' type found的错误提示(IntelliJ Idea)
- 【问题解决】 web项目启动不了 org.springframework.beans.factory.BeanCreationException: Could not autowire field:
- Could not autowire. No beans of 'UserMapper' type found.