java:S3749 'Members of Spring components should be injected' must be extended for Spring 3

Hi,

using Sonarqube Enterprise 9.9.0 with sonar-java-plugin-7.16.0.30901

This raises an issue for java:S3749 ‘Members of Spring components should be injected’

import jakarta.annotation.Resource;
[...]
@Resource
private RequestData requestData;

Even the latest version of Sonar Java, see https://rules.sonarsource.com/java/?search=Members%20of%20Spring%20components%20should%20be%20injected

has

This rule raises an issue when a singleton @Component, @Controller, @Service, or @Repository, not annotated with @ConfigurationProperties, has non-static members that are not annotated with one of:
[…]

  • javax.annotation.Resource

But with Spring 3 it’s jakarta.annotation.Resource. instead of javax.annotation.Resource

see
The Spring boot 3 release notes mention the use of Jakarta EE 9 (jakarta) instead of JEE (javax)

has

If you are trying an existing application with Spring Boot 3.0 you’ll need to be aware that we’ve migrated all Java EE APIs to their equivalent Jakarta EE variant.

Gilbert

1 Like

Hey Gilbert, thank you for the report.
We are aware that many classes were migrated to Jakarta packages, and we have some tickets to update our analyzers with this information.

I created a specific ticket for this one as you provided plenty of useful details.

Have a nice day!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.