基础概念
1.Spring 是一个轻量级的 IOC/DI 和 AOP 容器的开源框架。使用Spring框架的好处是什么?
2.什么是IOC(控制反转)思想?Spring中关于IOC思想的具体方式DI(依赖注入)?这篇文章
- IOC(inverse of control):控制反转
对象的创建以及依赖关系可以由spring完成和注入,即,在应用程序中对象的创建、销毁等不再由程序本身的编码实现,而是由外部的Spring容器在程序运行时根据需要注入到程序中,也就是对象的生命周期不是由程序本身来决定,而是由容器来控制,所以称之为控制反转。- DI,依赖注入(Dependency Injection)
1.Spring实现IoC思想是通过DI实现
2.注入方式:这篇文章
使用Setter方法注入(需要加注解@Autowired等,或者自己创建Bean,调用该Setter方法设进去);
构造器注入 (需要加注解@Autowired等,或自己创建Bean,放入构造器中创建);
3.Spring中核心组件Bean、Context、Core看这里
- ApplicationContext通常的实现是什么?
FileSystemXmlApplicationContext:从绝对路径中加载xml配置文件
ClassPathXmlApplicationContext:从项目的编译路径下加载xml
XmlWebApplicationContext:从项目的WEB-INF路径下加载xml - Spring Context初始化流程
4.AOP是什么?
具体开发相关
5.Spring配置的方式:xml、注解、API
6.Spring自动装配:byName、byType、Constructor、Autodetect(spring3.0之后过时,不再支持)
7.Spring自动装配集合:注解和xml
8.Spring内部bean、外部bean、父子bean
9.Spring常用的注解
- 类型类:
@Controller、@Service、@Repository、@Component、@Configuration - 设置类:
@Required、@Autowired和@Qualifier、@Scope - Web类:
@RequestMapping&&@GetMapping&&@PostMapping、@PathVariable&&@RequestParam、@RequestBody&&@ResponseBody - 功能类
@ImportResource、@ComponentScan、@EnableCaching&&Cacheable、@Transactional、@Aspect&&@Pointcut、@Scheduled
具体机制和实现原理
10.Spring中Placeholder动态替换机制和实现原理,有两种实现方式:PropertyPlaceholderConfigurer(常用)、PropertySourcesPlaceholderConfigurer
11.AOP实现的两种方式静态代理和动态代理
12.Spring中的事务
- 隔离级别和传播类型
13.Spring中核心接口和类:ApplicationContext、BeanFactory、BeanWrapper、FactoryBean
14.Spring中bean的作用于Scope
15.Spring的事件机制:ContextRefreshedEvent、ContextStartedEvent、ContextStoppedEvent、ContextClosedEvent、RequestHandledEvent