Spent many hours trying to figure out why my @Value annotations were not being resolved. My setup was :
In application-context.xml I was reading a properties file using:
classpath:application.properties, ..." />
Then I was attempting to set a variable using @Value.
After hours of searching, finally found some answers on Stack Overflow. The core issue seems to be scoping issues between root web context & servlet context.
actual processing of the @Value annotation is performed by a BeanPostProcessor….
BeanPostProcessor interfaces are scoped per-container. This is only relevant if you are using container hierarchies. If you define a BeanPostProcessor in one container, it will only do its work on the beans in that container. Beans that are defined in one container are not post-processed by a BeanPostProcessor in another container, even if both containers are part of the same hierarchy.
Also take note of the ‘order’ property, the lower the number the higher priority a PPC has. #1 is the first, #2 the second, etc… By default it has Integer.MAX_VALUE (it will be invoke last / the lowest possible priority).