Spring official document notes --- Bean

In Spring, the objects that form the backbone of your application and that are managed by the Spring IoC container are called beans.

In Spring, constituting the backbone of the application managed by the IOC container Spring objects referred bean. bean计算机中也称可重用组件
It is an example of a bean Spring IoC container, assembly and management of objects. Otherwise, bean is just one of many objects application program. Bean dependencies between them is reflected in the configuration used in the metadata container.

Spring container bean definition objects corresponding to the actual configuration of the application.

bean tag refelement refers to the name of another bean definition. Elements idand reflinks between elements express the dependencies between collaborators.

Let bean definitions across multiple XML files. Typically, each individual XML configuration files or modules represent logical layer architecture. By <import/>loading the bean definitions from another element or a plurality of files.

<beans>
    <import resource="services.xml"/>
    <import resource="resources/messageSource.xml"/>

    <bean id="bean1" class="..."/>
    <bean id="bean2" class="..."/>
</beans>

Named bean

<bean id = "person" name="person" class="com.minghai.Person" >

In XML-based configuration metadata, use idand / or namespecific bean identifier. idAttribute allows a specified id, the nameproperties other aliases can be introduced with ,, ;or 空格divided. Also it can be used in aliasthe introduction of an alias element.

<alias name="fromName" alias="toName"/>

Bean instantiation

Bean essence is used to create one or more objects of the recipe.

Guess you like

Origin www.cnblogs.com/minghaiJ/p/11516787.html