天道酬勤,学无止境

IOC容器

Explain dependency injection (DI) and Ioc container in detail

Simply put, the key technology is: Registrar mode. Scene requirements We know that when writing a class, the class itself has a purpose. There are many methods in the class, and each method handles some things; we call this class the main class. In addition, this main class will rely on the help of some other classes. We call these classes sub-classes. In order to achieve the goal of the main class, we need to rely on many sub-classes to cooperate, and the sub-classes are likely to be relied on by a wide range of main classes, for example: log class .Programming ideas Now let’s take an example

2021-05-18 15:43:59    分类:博客    IOC容器   依赖注入

Spring5 Reference Guide: IOC Container

Article Directory Why use Spring5What is an IOC containerConfiguration metadataInstantiate the container XML nesting groovy bean definition DSLUse containerRecently I am translating Spring Framework Documentation 5.1.8.RELEASE. I think it is still possible to systematically reorganize the knowledge points of Spring5, so with this Spring5 reference guide series, the tutorial will be updated all the time, and the translation will be performed simultaneously, please look forward to.Why use Spring5 After so many years of development, Spring has become an established enterprise-level J2EE standard

2021-05-13 12:30:31    分类:博客    Spring5   IOC容器

2021-03-30

Here is the quote/** * @Author: Promsing * @Date: 2021/3/19 - 11:50 * @Description: 模仿IOC容器,将创建的对象放在Map集合中,加载该类时会读取配置文件中,将类放入Map中 * @version: 1.0 */ public class BeanFactory {//定义一个properties对象 private static Properties props;//定义一个Map,用于存放我们创建的对象(单例,当类加载之后就有了对象,之后从Map中获取) private static Map<String,Object> beans; //容器 static {try {props=new Properties();//将bean.properties放在了resources路径下 InputStream is=BeanFactory.class.getClassLoader().getResourceAsStream("bean.properties");props.load(is);//实例化容器 beans=new HashMap<String,Object>();//从配置文件中获取所有key值 Enumeration<Object> keys = props.keys();while

2021-03-30 22:10:09    分类:博客    IOC容器   容器