This project demonstrates Setter Injection with Reference Type in the Spring Framework using XML Configuration.
An Employee object depends on an Address object. Spring IoC Container injects the Address bean into the Employee bean using the ref attribute.
- Spring IoC Container
- XML-based Configuration
- Setter Injection
- Reference Type Injection (
ref) - Dependency Injection
- Maven Project
- Java
- Spring Core
- Maven
- XML
SpringCore-SetterInjection-WithReference
│
├── src
│ └── main
│ ├── java
│ │ ├── com
│ │ │ └── configuration
│ │ │ └── application-context.xml
│ │ │
│ │ └── springcore
│ │ └── setterwithref
│ │ ├── App.java
│ │ ├── Employee.java
│ │ └── Address.java
│ │
│ └── resources
│
├── pom.xml
├── README.md
└── .gitignore
<bean id="address" class="springcore.setterwithref.Address">
<property name="city" value="Hyd"/>
<property name="pincode" value="457001"/>
</bean>
<bean id="employee" class="springcore.setterwithref.Employee">
<property name="id" value="101"/>
<property name="name" value="Prakhar"/>
<property name="add" ref="address"/>
</bean>Employee{id=101, name='Prakhar', add=Address{city='Hyd', pincode=457001}}
- Spring IoC Container
- Dependency Injection
- Setter Injection
- Reference Type Injection
- Bean Configuration using XML
- Bean Relationships
Prakhar Panchal