I'd like to know what are the differences between the two examples below. One is using @PostConstruct init method to ensure autowired bean is initialized, and the other one is using constructor with @Autowired to ensure any needed beans are initialized.
I am curious
- If there is any functional differences
- If one is better than the other, why? (Maybe initialization speed, less call stack, less memory usage, etc.)
Thanks in advance :)
@Component
public class MyBean {
    @Autowired
    public MyBean(SomeOtherBean someOtherBean) {
        ...
    }
    ...
}
@Component
public class MyBean {
    @Autowired 
    private SomeOtherBean someOtherBean;
    @PostConstruct
    public void init() {
        ...
    }
    ...
}
 
     
    