If I have the following code:
Class A {
@Autowired
private B b;
private List<B> bList = ImmutableList.<B>builder().add(b).build();
}
even if the Spring is configured correctly for the package, for both class A and class B (verified by removing the ImmutableList line and using a method to set that variable instead and not changing any spring configuration), even then the above code with throw NullPointerException
as b
will not be initialized at that point I think. Is there any way to make Spring to initialize b first and then use that in the ImmutableListBuilder?