This project demonstrates Mixed Dependency Injection in the Spring Framework using XML Configuration.
The project consists of two classes:
- Manager – Created using Constructor Injection
- Project – Receives the
Managerobject through Constructor Injection, while its own properties (projectNameandduration) are initialized using Setter Injection.
This example illustrates how constructor and setter injection can be combined in a real-world scenario.
- Spring IoC Container
- XML-based Bean Configuration
- Constructor Injection
- Setter Injection
- Reference Type Injection
- Mixed Dependency Injection
- Maven Project
- Java
- Spring Core
- Maven
- XML
SpringCore-MixedInjection
│
├── src
│ └── main
│ ├── java
│ │ ├── com
│ │ │ └── configuration
│ │ │ └── application-context.xml
│ │ │
│ │ └── springcore
│ │ └── SetterAndConstructorInjection
│ │ ├── App.java
│ │ ├── Project.java
│ │ └── Manager.java
│ │
│ └── resources
│
├── pom.xml
├── README.md
└── .gitignore
<bean id="manager" class="springcore.SetterAndConstructorInjection.Manager">
<constructor-arg value="Ravi Shankar"/>
<constructor-arg value="IT"/>
</bean><bean id="project" class="springcore.SetterAndConstructorInjection.Project">
<constructor-arg ref="manager"/>
<property name="projectName" value="Employee Management System"/>
<property name="duration" value="6 Months"/>
</bean>Project [
projectName=Employee Management System,
duration=6 Months,
manager=Manager [managerName=Ravi Shankar, department=IT]
]
- Spring IoC Container
- Dependency Injection
- Constructor Injection
- Setter Injection
- Reference Type Injection
- Mixed Dependency Injection
- XML Bean Configuration
Prakhar Panchal