Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Spring Core - Setter Injection with Reference Type

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.


🚀 Features

  • Spring IoC Container
  • XML-based Configuration
  • Setter Injection
  • Reference Type Injection (ref)
  • Dependency Injection
  • Maven Project

🛠 Technologies Used

  • Java
  • Spring Core
  • Maven
  • XML

📂 Project Structure

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

XML Configuration

<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>

Output

Employee{id=101, name='Prakhar', add=Address{city='Hyd', pincode=457001}}

Concepts Covered

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

Author

Prakhar Panchal

About

Spring Core project demonstrating Setter Injection with reference type using XML configuration to inject an Address object into an Employee bean.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages