Javatpoint Logo

Dependency injection by Constructor

By: mohd.i*** On: Sun Jun 04 00:10:48 IST 2017     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
Can we invoke default constructors by Spring IOC Container.

Please if possible then reply me the way to achieve

eg

class Employee {
private int id;
private String name;
Employee() {} // How to call it by Spring container
public Employee(int id) {
this.id=id;
}
public Employee(String name) {
this.name=name;
}
public Employee(int id, String name) {
this.id=id;
this.name=name;
}
public void show() {
System.out.println(id+" "+name);
}
}
Up0Down