I have a property set to "true", that I want to bind to my checkStatus field.
@Value("${prop.checkstatus}")
private boolean checkStatus;
I am able to access the value from inside an @Service class. However, if I use @Value inside a class that I instantiate or retrieve using AppliationContext.getBean("classA"), the value is always "false" since it cannot get the correct value from the property file. Please advise as I need to access this value from an instance and from a bean.
In some parts of the code, I create the object using new and try to access @Value. I understand that this is not possible since the new object is not managed by spring. But there are parts of the code where the object is retrieved using applicationcontext. Still I cannot access the @Value. Is there a better approach in retrieving @Value both for objects created using new and applicationcontext.getbean?