In spring wiring is there a way to get the properties defined in application.properties to be wired to the corresponding field annotated with @Value before the constructor call.
Please see my comment in below code. I want the field prop1 (with its value) to be available to the constructor. Is it possible. Similarly I want the field prop1 (with its value) to be available to the getInstanceProp() method. Is it possible??
package com.demo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class WirableComponent {
@Value("${prop1}")
String prop1;
String instanceProp = getInstanceProp(); //null - I want prop1 value to be injected before making this method call so i can use it in the method.
public WirableComponent() {
System.err.println("no-args WirableComponent Constructor invoked");
System.err.println("value prop1: " + prop1); //null - I want prop1 value to be injected before constructor call so i can use it in constructor.
System.err.println("value instanceProp: " + instanceProp); //null
}
public String getInstanceProp() {
System.err.println("value prop1: " + prop1);
return null;
}
}