獲取spring裡的bean

x號開發者發表於2019-03-29

 

ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");

UserService userService = (UserService) applicationContext.getBean("userServiceImpl");

 

ClassPathXmlApplicationContext    可以用來讀取xml檔案

相關文章