IntelliJ IDEA shows errors when using Spring's @Autowired annotation IntelliJ IDEA shows errors when using Spring's @Autowired annotation spring spring

IntelliJ IDEA shows errors when using Spring's @Autowired annotation


I had the same problem with IntelliJ IDEA 13.1.4I solved it by removing the Spring facet (File->Project Structure) and leaving it to just show "Detection".


I fixed it by adding the supress warning:

 @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") @Autowired private ....


If you know that the bean exists and its just a problem of the inspections, then just add the following before the variable declaration:

@SuppressWarnings("SpringJavaAutowiringInspection")@Inject MyClass myVariable;

Sometimes IntelliJ cannot resolve if a bean has been declared, for example when the bean is included conditionally and the condition resolution happens dynamically at runtime. In such a case it seems the static code analyzer of IntelliJ cannot detect the bean.