It's always good to start with the most common option. So first, we will take an example of pure XML-based configuration, as per the following snippet:
public class Professor { private String name; //Constructor public Professor() { System.out.println("Object of Professor is created"); } public String getName() { return name; } public void setName(String name) { this.name = name; }}public class Subject { private Professor professor; public Subject() { System.out.println("Object of Subject is created"); } //Setter injection method public void setProfessor(Professor professor) { System.out.println("setting the professor through setter method injection "); this.professor = professor; } public void taughtBy() { if(professor ...