Skip to content

Prakharpanchal7240/SpringCore-ConstructorInjection-WithReference

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Spring Core - Constructor Injection with Reference Type

This project demonstrates Constructor Injection with Reference Type in the Spring Framework using XML Configuration.

A Patient object depends on a Doctor object. Spring IoC Container injects the Doctor bean into the Patient bean using constructor injection and the ref attribute.


🚀 Features

  • Spring IoC Container
  • XML-based Configuration
  • Constructor Injection
  • Reference Type Injection
  • Dependency Injection
  • Maven Project

🛠 Technologies Used

  • Java
  • Spring Core
  • Maven
  • XML

📂 Project Structure

SpringCore-ConstructorInjection-WithReference
│
├── src
│   └── main
│       ├── java
│       │   ├── com
│       │   │   └── configuration
│       │   │       └── application-context.xml
│       │   │
│       │   └── springcore
│       │       └── constructor_inj_with_refrence
│       │           ├── App.java
│       │           ├── Patient.java
│       │           └── Doctor.java
│       │
│       └── resources
│
├── pom.xml
├── README.md
└── .gitignore

XML Configuration

<bean id="doctor" class="springcore.constructor_inj_with_refrence.Doctor">

    <constructor-arg value="R.D. Patel"/>
    <constructor-arg value="Plastic Surgery"/>

</bean>

<bean id="patient" class="springcore.constructor_inj_with_refrence.Patient">

    <constructor-arg value="Prakhar"/>
    <constructor-arg value="23"/>
    <constructor-arg ref="doctor"/>

</bean>

Output

Patient [name=Prakhar, age=23, doctor=Doctor [doctorName=R.D. Patel, specialization=Plastic Surgery]]

Concepts Covered

  • Spring IoC Container
  • Dependency Injection
  • Constructor Injection
  • Reference Type Injection
  • XML Bean Configuration
  • Bean Relationships

Author

Prakhar Panchal

About

Spring Core project demonstrating Constructor Injection with reference type using XML configuration to inject a Doctor object into a Patient bean.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages