Spring Framework

Scan the following class and call its method:
 
@Component
public class BaseballCoach(){
      public void teach(){
                 System.out.println("Coaching");
}

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
 
Coach coach = context.getBean("baseballCoach", BaseballCoach.class);
 
coach.teach();
 
context.close();

Diskussion