It's not possible to use @Value
on a static variable.
@Value("${some.value}")
static private int someValue;
static public void useValue() {
System.out.println(someValue);
}
When I do this, 0
is printed. So what is a good alternative to this?
Spring inject noting in static field (by default).
So you have two alternatives:
@Value
annotation to the setter.@Value
too