What is spring bean container? --- On the surface, it is a class + xml document, that is, the ApplicatonContext class and the spring configuration file beans. xml. We often write the following statement 12345 // instantiate spring container ApplicationContext ctx = new FileSystemXmlApplicationContext ("beans. xml "); // the file system is used to load the xml file. This is not the best method. We should use the class path to load the xml file, because different hosts have different file systems. // Obtain xx = ctx of a class. getBean ("XX id"); --- in essence, it uses the factory mode and the default Singleton mode to help us instantiate the bean we configured in xml and create the bean object, destruction and other lifecycle operations are carried out in a centralized place. If we want to use a bean, we will go to this place for retrieval.. The following <bean element. Copy the Code <? Xml version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id = "personDao" class = "cn. can. dao. personDao "/> <bean...> ..... </beans> the copy code is obvious. We configure our classes in the xml document, and then parse the xml document. This is an example of the parsing process. Here we should consider 1) How does spring create beans? What is its lifecycle? Load xml to parse xml. These beans are instantiated using the launch mechanism and the class describing the bean. Therefore, the default constructor of the bean is required. In this case, the factory is used to generate the class. In this factory, you only need to tell me that the class has the interface feature to get this class. 2) Is it a static factory instance or something else? Is this bean created using the singleton mode or prototype? What is the bean lifecycle? When will the instance be executed ?. When scope = "singleton" and lazy-init = 'default', the container is instantiated during loading, however, here lazy-init = 'true', the instantiation will be delayed. When scope = 'prototype', it is delayed instantiation.