步骤和web project一样,但是一定要注意,web project的入口是web.xml,而java project里没有web.xml.需要在main方法里引入application-Context.xml的配置文件。
String[] context = new String[]{"/applicationContext.xml"};
ApplicationContext config = new ClassPathXmlApplicationContext(context);
accountManager = (AccountManager) config.getBean("accountManager");
System.out.println(accountManager.getAllRole().size());
org.springframework.context.support.ClassPathXmlApplicationContext .ClassPathXmlApplicationContext(String ... configLocations) throws BeansException