intellij错误地说没有为自动装配的存储库找到类型的bean [英] intellij incorrectly saying no beans of type found for autowired repository

查看:2051
本文介绍了intellij错误地说没有为自动装配的存储库找到类型的bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的单元测试,但IntelliJ错误地将其突出显示为红色。将其标记为错误

I have created a simple unit test but IntelliJ is incorrectly highlighting it red. marking it as an error

没有豆?

如下所示,它通过了测试?那么它必须是自动装配?

As you can see below it passes the test? So it must be Autowired?

推荐答案

使用<$ c $创建 Spring Boot 应用程序时遇到同样的问题c> @SpringBootApplication 注释。此注释表示 @Configuration @EnableAutoConfiguration @ComponentScan 根据弹簧参考

I had this same issue when creating a Spring Boot application using their @SpringBootApplication annotation. This annotation represents @Configuration, @EnableAutoConfiguration and @ComponentScan according to the spring reference.

正如预期的那样,新的注释工作正常,我的应用程序运行顺利,但 Intellij 一直在抱怨未实现的 @Autowire 依赖项。一旦我改回使用 @Configuration @EnableAutoConfiguration @ComponentScan ,错误停止。似乎 Intellij 14.0.3 (很可能,早期版本)尚未配置为识别 @SpringBootApplication 注释。

As expected, the new annotation worked properly and my application ran smoothly but, Intellij kept complaining about unfulfilled @Autowire dependencies. As soon as I changed back to using @Configuration, @EnableAutoConfiguration and @ComponentScan separately, the errors ceased. It seems Intellij 14.0.3 (and most likely, earlier versions too) is not yet configured to recognise the @SpringBootApplication annotation.

现在,如果错误打扰你那么多,那么回到那三个单独的注释。否则,忽略 Intellij ...您的依赖项解析已正确配置,因为您的测试通过了。

For now, if the errors disturb you that much, then revert back to those three separate annotations. Otherwise, ignore Intellij...your dependency resolution is correctly configured, since your test passes.

永远记住......

Always remember...


人总是大于机器。

Man is always greater than machine.

这篇关于intellij错误地说没有为自动装配的存储库找到类型的bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆