@Autowired annotation itself annotated with
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
This means that it can only be used to annotate constructors, fields, methods, or other types of annotations. It cannot be used for local variables.
Even if it is possible , nothing Spring or any runtime can do this, because reflection does not provide any bindings in the method bodies. You cannot access this local variable at run time.
You will have to move this local variable to the field and auto-university.
Sotirios delimanolis
source share