public class Demo { public static void main(String[] args) { ApplicationContext mAppCtx = new FileSystemXmlApplicationContext("classpath:applicationContext-resources.xml"); ICallService callService ; //查看所有的bean String[] str = mAppCtx.getBeanDefinitionNames(); for (String s : str){ System.out.println(s); } //获取名为ICallService的bean callService= mAppCtx.getBean(ICallService.class); System.out.println(callService); } }
使用FileSystemXmlApplicationContext将bean加入spring容器中管理
最新推荐文章于 2024-03-29 05:30:00 发布