您的位置:首页 > 编程语言 > Java开发

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,如下:

<!-- 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.保存,就不会再报错了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring idea eclipse
相关文章推荐