From the course: Spring: Framework in Depth

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Init: Setters

Init: Setters

From the course: Spring: Framework in Depth

Start my 1-month free trial

Init: Setters

- [Instructor] So after objects are constructed, we can now call setters on them, and that is what the Spring framework does next. So again, back to where we are. So we've instantiated our beans, and now we're ready to do setter calling. So, post-initialization dependency injection should only be done on optional beans or dynamic beans, and that's really important to remember that concept. Anything that is required for your class to operate should have been injected via a constructor. Now there's no way for the application context in the IOC container to know which is which. This is is just good development practice. So after all beans have been instantiated, we can go through and call the setter on each object, which, go back to object-orient programming and working with Java, right, you have to construct the object to call any methods on it including setters. Autowiring will occur here on all methods that are not…

Contents