main函数测试时,可以用下面的SrpingUtils
public class SpringUtils {
static ApplicationContext context = null;
static {
context = new ClassPathXmlApplicationContext("applicationContext.xml");
}
public static <T> T getBean(Class<T> type) {
return context.getBean(type);
}
}