spring实例化时
- public void test2() {
- ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
- //配置文件中的id属性
- IHelloService service = (IHelloService) context.getBean("helloService");
- service.sayHello();
- }
-
- public void test2() {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
- //配置文件中的id属性
- IHelloService service = (IHelloService) context.getBean("helloService");
- service.sayHello();
- context.close();
- }