You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

IOC

创建对象的过程从原来的new变为由Spring控制对象创建并将创建好的对象统一交给容器管理。配合依赖注入实现了对象的创建与使用解耦开发者只关心使用

上下文

提供了操作容器的统一API入口可以通过调用直接创建Bean、或者读取配置等

AOP

利用代理机制实现横向抽象,例如@transactional和@Async 注解都是通过注解拦截器读取到被注解类,然后生成代理对象,例如事务注解,自动加入开启事务、提交事务、回滚事务。

为什么使用三级缓存

因为初始化bean并赋属性以及依赖关系注入不是同步的过程而是异步完成例如有些bean已经注入到其他bean但是此时它的属性并没有完全赋值导致早期bean和最终bean不一致也是个一致性问题。所以需要使用三级缓存解决。

Bean的生命周期

  1. bean元数据配置读取、解析
  2. 注册到容器
  3. bean class加载
  4. 属性赋值
  5. 初始化创建
  6. 使用
  7. 销毁