ApplicationContext context = new ClassPathXmlApplicationContext(
"spring/applicationContext.xml");
"spring/applicationContext.xml");
InfoService noticeTemp= (InfoService)context.getBean("InfoService");
//"spring/applicationContext.xml"为spring设置
//InfoService为注入的bean Id 这里注意bean写的完成类,InfoService必须为接口
noticeTemp.selectTempNotice();//点调自己写的方法就可以了
另外一定要写set,get方法,不然汇报空指针异常