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 ref
element refers to the name of another bean definition. Elements id
and ref
links 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 id
and / or name
specific bean identifier. id
Attribute allows a specified id, the name
properties other aliases can be introduced with ,
, ;
or 空格
divided. Also it can be used in alias
the 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.