For all my @Component and @Service, I use
@RequiredArgsConstructor(onConstructor = @__(@Autowired)).
It makes the code much cleaner an works just fine.
But SonarQube only accepts this for components. All fields in the service classes have the critical issue:
"Annotate this member with "@Autowired", "@Resource", "@Inject", or "@Value", or remove it."
Is there a solution to fix it or a workaround? I don't want to disable the rule, because it helps sometimes.
My code:
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class fooService {
private final FooDAO fooDAO; // Annotate this member with "@Aurowired"...
// rest of the class
}