第一篇先对Spring底层原理进行大致介绍。
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
UserService userService = (UserService) context.getBean("userService");
userService.test();
这段代码相信接触过Spring的同学都会非常熟悉。他就像spring里的hello world。但是classPathXmlApplicationContext其实已经过时了,新版的SpringMVC和Spring Boot底层用的都是AnnotationConfigApplicationContext。
例如以下代码
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
//ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
UserService userService = (