I have created a simple unit test but IntelliJ is incorrectly highlighting it red. marking it as an error
No beans?
I always solve this problem doing de following.. Settings>Inspections>Spring Core>Code than you shift from error to warning the severity option
This seems to still be a bug in the latest IntelliJ and has to do with a possible caching issue?
If you add the @Repository annotation as mk321 mentioned above, save, then remove the annotation and save again, this fixes the problem.
For me the solution was to place @EnableAutoConfiguration
in the Application class under the @SpringBootApplication
its going to underline it because its redundant. Delete it and voila all you warnings regarding missing beans are vanished! Silly Spring...
simple you have to do 2 steps
@Autowired
to @Resource
.==>> change @Autowired to @Resource
My version of IntelliJ IDEA Ultimate (2016.3.4 Build 163) seems to support this. The trick is that you need to have enabled the Spring Data plugin.
Use @EnableAutoConfiguration
annotation with @Component
at class level. It will resolve this problem.
For example:
@Component
@EnableAutoConfiguration
public class ItemDataInitializer {
@Autowired
private ItemReactiveRepository itemReactiveRepository;
@Autowired
private MongoOperations mongoOperations;
}