Find uninjected members of Spring components

Proprietary

Marks a non-static field of a singleton class annotated with @Component, @Service, @Repository, @Controller or @RestController when Spring does not inject it. Such a class has one instance for the whole application, so a field Spring does not manage is state shared by every caller. A field is left alone when it is annotated with @Autowired, @Value, @Inject, @Resource, @PersistenceContext or @PersistenceUnit; when it is referenced in the class's only constructor, in a constructor that carries one of those annotations, or in a constructor such a constructor delegates to with this(..); when a non-static method of the class that carries one of those annotations, such as an @Autowired setter, assigns it as field or this.field, not in a lambda or nested class; or when Lombok injects it through @RequiredArgsConstructor or, in a class without an explicit constructor or @NoArgsConstructor, @Data (no initializer or @Builder.Default, and final, also through @FieldDefaults(makeFinal = true), or carrying a non-null annotation Lombok recognizes, such as @NonNull) or @Value or @Builder (no initializer, not final, or @Builder.Default). Classes annotated with @ConfigurationProperties or Lombok's @AllArgsConstructor are skipped, as are classes whose @Scope is not singleton or names it through a constant other than Spring's SCOPE_SINGLETON, and classes with a scope annotation such as @RequestScope, known by name or by its own @Scope. Apart from @Scope, annotations are matched directly, not through meta-annotations, and nothing is marked when an annotation's type is unknown. Test sources are not searched.

io.moderne.java.spring.framework.FindUninjectedSpringComponentMember
mod run . --recipe=io.moderne.java.spring.framework.FindUninjectedSpringComponentMember

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.