I have a simple web-app that includes a dependency jar for some functionality and needs to use a property value defined in main app code.
Thanks in advance to help me out on this.
dependency.jar contains
public class MyClass {
@Value("${abc.def}")
private String abc; // DOES NOT GET RESOLVED. IS ALWAYS NULL
}
dependency-context.xml
my-app.war contains
public class LocalClass {
@Value("${abc.def}")
private String abc; // GETS RESOLVED TO CORRECT PROPERTY VALUE
}
context.xml imports dependency-context.xml
You may be running into this bug. It makes it very difficult to use the @Value with multiple PropertyPlaceholderConfigurers from different projects using import context. To solve this problem try to autowire the existing PropertyPlaceholderConfigurer into your bean configuration method (assuming you can use @Configuration) and update the object in the method with the values from your project.