Getting "Annotate this member with "@Autowired", "@Resource", "@Inject", or "@Value", or remove it."
while running sonar for one of my spring-boot project.
-
Versions used :
- Sonar Qube : 8.4.1
- Java 8
- spring-boot-dependencies.version : 2.2.5.RELEASE -
Error observed :
"Annotate this member with "@Autowired", "@Resource", "@Inject", or "@Value", or remove it.".
-
Steps to reproduce :
- You can use this config class and can reproduce this issue.
import lombok.Getter; import lombok.Setter; import a.b.c.d.ABCConfig; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @Component @ConfigurationProperties("abc-service") @Getter @Setter public class DefConfig { private String url; private ABCConfig abc = new ABCConfig(); @Configuration @Import(DefConfig.class) public class DefContext { }
It actually not recognizing the advantage/usage of @ConfigurationProperties
.