I have an abstract class in which I am trying to use the @Value annotation to inject value from a property file
public abstract class Parent {
@Value (\"${s
I think you'll find the sharedVal is being set, but you're trying to use it too soon in the constructor. The constructor is being called (must be called) before Spring injects the value using the @Value
annotation.
Instead of processing the value in the constructor, try a @PostContruct
method instead, eg:
@PostConstruct
void init() {
//perform common action using sharedVal
}
(or alternatively, implement Spring's InitializingBean interface).