IntelliJ Idea取消Colud not autowire.No
生活随笔
收集整理的這篇文章主要介紹了
IntelliJ Idea取消Colud not autowire.No
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
轉載:https://www.cnblogs.com/waterystone/p/6214212.html
1.問題描述
在Idea的spring工程里,經常會遇到Could not autowire. No beans of ‘xxxx’ type found的錯誤提示。但程序的編譯和運行都是沒有問題的,這個錯誤提示并不會產生影響。但紅色的錯誤提示在有些有強迫癥的程序員眼里,多多少少有些不太舒服。
2.原因
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>3.解決方案
降低Autowired檢測的級別,將Severity的級別由之前的error改成warning或其它可以忽略的級別。
總結
以上是生活随笔為你收集整理的IntelliJ Idea取消Colud not autowire.No的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 买基金怎么分辨板块
- 下一篇: 苹果计划在印度组装iPad 避免对中国制