I defined my properties file location on XML, and register my custom util class as bean. (with factory-method is “getInstance”)
What I want is I want to load my properties value before my Custom util construction us called.
class AUtil
{
private static AUtil instance;
@Value("something")
private m;
private AUtil() {}
public static AUtil() {
if (instance == null) instance = new AUtil();
return instance;
}
}
I think you should use @PostConstruct as: when the constructor is called, the bean is not yet initialized - i.e. no dependencies are injected. In the @PostConstruct method the bean is fully initialized and you can use the dependencies.