Posts

Showing posts with the label Dependency Injection

Spring - Initializing a Spring Bean

Image
It is often required to run some custom code on initialization of a Spring bean. e.g. to check for mandatory properties or establish initial connections. Spring provides a few constructs to initialize the beans after they are injected with the properties.

Spring - Lookup Method or Method Injection

Image
Most common injection mechanisms used in Spring are Constructor and Property injections. In both the mechanisms, the injection happens only once during the initialization of the Bean. They also require a concrete method defined, e.g., a constructor method for constructor injections and a setter method for property injection.