Archives: Spring

Java Spring – Constructor Injection Example

spring-config.xml

Employee.java

Address.java

EmployeeAddress.java

Output:

INFO: Loading XML bean definitions from file [D:\workspace\SpringProject\src\spring-config.xml]
Employee: Name: Prasanna
Age: 26
Address: City: Amravati
State: Maharashtra

Java Spring – Setter Injection Example

spring-config.xml

Employee.java

Address.java

EmployeeAddress.java

Output:

INFO: Loading XML bean definitions from file [D:\workspace\SpringProject\src\spring-config.xml]
Employee: Name: Prasanna
Age: 26
Address: City: Amravati
State: Maharashtra