Spring / Spring interview questions
How do I Inject value into static variables in Spring bean?
Spring does not allow injecting to public static non-final fields. So the workaround will be changing to private modifier.
Another workaround will be to create a non static setter to assign the injected value for the static variable.
@Value("${my.name}") public void setName(String privateName) { ThisClass.name = privateName; }
More Related questions...