Spring containers allow injection of List
, Set
, Map
, or Properties
objects to other Spring-defined beans through <property>
tags. The following recipe will distinguish between XML-based and JavaConfig
context definitions when it comes to implementing type-safe injection.
Reopen ch02-xml
and ch02-jc
for this recipe. We will be injecting a few POJO objects to both of the containers in our projects.
Perform the following steps to auto-wire Collections and Properties components:
- For both of the projects involved in the preceding recipes, create the following model classes inside their own package
org.packt.starter.ioc.model
:
public class ListEmployees { private List<Employee> listEmps; private List<String> listEmpNames; // getters and setters } public class SetDepartments { private Set<Department> setDepts; private Set<String> deptNames; // getters and setters } public...