So in Spring dependency injection enables us to add functionality from other classes to our implementations of object interfaces. We add these dependencies as member variables of implementation classes, then make functions to use these member variables. The configuration is done via XML where we create a bean config tag for the dependency and add either constructor or setter injection. Constructor injection requires the dependency is initialized through a constructor while setter injection requires the dependency is initialized through a setter method. There are nuances to the tags needed to create the configuration for these two methods. I would recommend looking at the xml config file of the spring-demo-one app to see these nuances.
No comments:
Post a Comment