Spring @Autowire error "more than one bean"
已回答
When a bean implementation exists both in the production and test codes, IntelliJ will mark @Autowired instances of this bean as "cannot autowire, more than one bean...".
This is of course incorrect, as the test implementation will never be deployed in a production environment.
In the project I'm looking at the beans are defined with @Bean annotations in classes annotated with @Configuration, but the same happens with @Services
The tests and application itself run just fine, this is just an erroneous error mark in the IDE but is annoying.
Searching back in the forums this may be a regression.
Running the latest IntelliJ (2019.1.3) on Windows and Mac.
请先登录再写评论。
Hi. Could you please provide a demo project?
Hi, please try https://github.com/igorkosandyak/spring-boot-with-hazelcast
Hi.
I have raised a bug report, please follow: https://youtrack.jetbrains.com/issue/IDEA-227133
As a workaround please add a qualifier as inspection suggests.
With @ConditionalOnProperty or such annotation's help , actually more than one beans exist in my application with no problem , except that intelij mark it as an error