我已经创建了一个简单的单元测试,但是IntelliJ错误地将它突出显示为红色。将其标记为错误
没有豆子?
如你所见,它通过了测试?所以它一定是自动连接的?
我已经创建了一个简单的单元测试,但是IntelliJ错误地将它突出显示为红色。将其标记为错误
没有豆子?
如你所见,它通过了测试?所以它一定是自动连接的?
当前回答
只要你的测试通过了,你是好的,点击alt + enter,将光标移到错误上,在第一项的子菜单中,你会发现禁用检查,选择它
其他回答
简单,你只需要做2步
添加休眠内核依赖项 将@Autowired改为@Resource。
==>> change @Autowired to @Resource
只要你的测试通过了,你是好的,点击alt + enter,将光标移到错误上,在第一项的子菜单中,你会发现禁用检查,选择它
I had similar issue in Spring Boot application. The application utilizes Feign (HTTP client synthetizing requests from annotated interfaces). Having interface SomeClient annotated with @FeignClient, Feign generates runtime proxy class implementing this interface. When some Spring component tries to autowire bean of type SomeClient, Idea complains no bean of type SomeClient found since no real class actually exists in project and Idea is not taught to understand @FeignClient annotation in any way.
解决方案:用@Component注解接口SomeClient。(在我们的例子中,我们没有直接在SomeClient上使用@FeignClient注释,而是使用metaannotation @OurProjectFeignClient,它是带注释的@FeignClient,并向其添加@Component注释也可以工作。)
在我的情况下,我试图@Autowired的目录不在同一级别,
将其设置在同一结构层后,错误消失了
希望对大家有所帮助!
只需添加以下两个注释到您的POJO。
@ComponentScan
@Configuration
public class YourClass {
//TODO
}