https://download.csdn.net/download/weixin_41957626/87546826 资源地址
图1 spring3的体系结构图
图2 spring4体系结构图
比较spring3的体系结构图,spring4去掉了spring3中的struts模块,添加了messaging模块和websocket模块,其他模块保持不变。spring的jar包有20个。
1.下面是spring4和5的区别?
在增强开发方面spring4是web开发增强,spring5是JDK8的增强。
在特性改进方面spring4是注解、脚本、任务、MVC等其他特性改进,spring5是测试方面的改进。
1.控制反转或者是依赖注入的含义。面向接口的编程。
2.实现方式
1.依赖导入
org.springframework
spring-context
5.3.24
2.创建配置文件
3.项目目录
图3 项目目录
4.实现的代码
采用的是gif的形式展示
图4 spring代码展示
测试类代码
@Test
public void testContext(){
//采用的是读取xml的文件的配置形式
ApplicationContext context= new ClassPathXmlApplicationContext("Spring-context.xml");
StudentService service1= context.getBean(StudentService.class);
StudentService service2= (StudentService)context.getBean("studentService");
System.out.println(service1);
System.out.println(service2);
service1.addStudent(new Student(1,"张三"));
}
图5 效果图