I have a configuration file as such which is creating a bean ,
@Bean
public A a() {
return A.method(x,y,z);
}
In the class A , the constructor seems to be private and the code is as such,
public class A implements SomeInterface () {
@Autowired
private Property property // want this to be autowired
private A(int x, int y....) { //private constructor
this.x = x;
....
}
public static method(int x, int y, intz) { //method being called
return new A (x,y,z...);
}
public static method2(int x,....) {
return new A(x,y...)}
}
When instance of A is created, it is showing property = null. Wondering why property was not autowired even though A is supposedly spring managed. Issue seems to be that it is not even trying to autowire else it should give error related to bean not found or such.
I cannot edit these files since they are libraries but just want to understand why autowiring is not happening. Could it be because of calling the static method for creation?