1. In spring, bean is Singleton in singleton mode by default. The default value is lazy-load.
2. During lazy-load, the Bean factory will load the definition information, but it will only instantiate it when explicitly calling it. When a quartz timer task is configured in spring, the following configuration is used: the "sfactory" display is not specified as loading immediately at the beginning, causing the task to fail to run. <? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype beans public "-// spring // DTD bean // en" "http://www.springframework.org/dtd/spring-beans.dtd">
<Beans default-Lazy-init = "true">
<! -- Spring scheduling factory -->
<Bean id = "sfactory"
Class = "org. springframework. Scheduling. Quartz. schedulerfactorybean"
Singleton = "true" lazy-init = "false">
<Property name = "triggers">
<List>
<Ref local = "crontrigger"/>
</List>
</Property>
</Bean>
<! -- Trigger triggered by spring -->
<Bean id = "crontrigger"
Class = "org. springframework. Scheduling. Quartz. crontriggerbean">
<Property name = "jobdetail">
<Ref bean = "examplejob"/>
</Property>
<Property name = "cronexpression">
<! -- Run every morning at 6 am -->
<Value> 0 0 03 **? </Value>
</Property>
</Bean>
<! -- Task implementation class -->
<Bean name = "examplejob"
Class = "org. springframework. Scheduling. Quartz. jobdetailbean">
<Property name = "jobclass">
<Value> com. decentsoft. smmail. Mail. task. trashcatalogcleartask </value>
</Property>
<Property name = "jobdataasmap">
<Map>
<Entry key = "mailoperationservice">
<Ref bean = "mailoperationservice"> </Ref>
</Entry>
</Map>
</Property>
</Bean>
</Beans>
3. Bean loading process:
1) The container looks for bean definition information and instantiates it.
2) using dependency injection, spring configures all bean attributes according to bean definition information.
3) if the beannameaware interface is implemented, the factory will call the setbeanname () of bean to the bean ID
4) if the beanfactoryaware interface is implemented, the factory calls the setbeanfactory () method to pass it to the factory itself.
5) If beanpostprocessor is associated with bean, their postprocessbeforeinitialation () will be called.
6) if the bean specifies the init-method, it will be called.
7) If beanpostprocessor is associated with bean, their postprocessafterinitialation () will be called.
Bean destruction:
1) The disposablebean interface can be implemented.
2) Specify the custom destroy Method When configuring bean.