Could not autowire. No beans of ‘xxxx’ type found
源码是这样的 主要是是因为出现了下划线变红
@RunWith(SpringRunner.class)
@SpringBootTest
class MallApplicationTests {
@Autowired
// private CategoryMapper categoryMapper;
private CategoryMapper categoryMapper;
对应的出现错误提示

出现原因
**spring auto scan配置,在编辑情况下,无法找不到对应的bean,不能自动装配**
解决方法
降低Autowired检测的级别

但是该错误本质上是不影响代码的正确执行的
如果 还是不行报错 就是自己的代码逻辑有问题了
本文探讨了Spring框架中@Autowired注解在使用时遇到的'No beans of 'xxxx' type found'错误。该问题源于Spring的自动扫描机制无法找到匹配的bean进行装配。解决方法包括调整Autowired的检测级别,尽管这并不影响代码实际运行。当降低检测级别无效时,问题可能出在代码逻辑上。博客内容着重于理解错误原因和提供解决方案。
4232

被折叠的 条评论
为什么被折叠?



