5.2.3.使用容器
在ApplicationContext中调用方法T getBean(String name, Class<T> requiredType)你就可以获得你定义Bean的实例化对象。如下例所示:
// create and configure beansApplicationContext context =new ClassPathXmlApplicationContext(new String[] {"services.xml", "daos.xml"});// retrieve configured instancePetStoreService service = context.getBean("petStore", PetStoreService.class);// use configured instanceList<String> userList = service.getUsernameList();
