Spring @Component, @Controller, @RestController,@Service, and @Repository classes
are singletons by default, meaning only one instance of the class is ever instantiated in the application. Typically such a class might have a few
static members, such as a logger, but all non-static members should be managed by Spring.
This rule raises an issue when a singleton @Component, @Controller, @RestController, @Service,
or @Repository, not annotated with @ConfigurationProperties, has non-static members that are not annotated with
one of:
-
org.springframework.beans.factory.annotation.Autowired
-
org.springframework.beans.factory.annotation.Value
-
javax.annotation.Inject
-
javax.annotation.Resource
-
javax.persistence.PersistenceContext
-
jakarta.annotation.Resource
-
jakarta.inject.Inject
-
jakarta.persistence.PersistenceContext