IOC之基于注解的配置bean(下)
立即下载
资源介绍:
IOC之基于注解的配置bean(下),具体效果和过程看博文
http://blog.csdn.net/evankaka/article/details/45077041
package com.mucfc.test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.mucfc.service.MyComponent;
import com.mucfc.service.MySerivce;
public class Test {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
MySerivce service= context.getBean("service", MySerivce.class);
MyComponent myComponent=context.getBean("myComponent", MyComponent.class);
System.out.println("--------list--------");
for (int i = 0; i < myComponent.getUserList().size(); i++) {
System.out.println(myComponent.getUserList().get(i));
}
System.out.println(service.getUserDao());
;
((ClassPathXmlApplicationContext)context).destroy();
}
}