Spring Bean的基本概念

1、定义 Spring Bean :BeanDefinition

一下代码只是BeanDefinition中的部分代码,如果想详细了解,可以自行查找API

/**
 * A BeanDefinition describes a bean instance, which has property values,
 * constructor argument values, and further information supplied by
 * concrete implementations.
 *
 * <p>This is just a minimal interface: The main intention is to allow a
 * {@link BeanFactoryPostProcessor} such as {@link PropertyPlaceholderConfigurer}
 * to introspect and modify property values and other bean metadata.
 *
 * @author Juergen Hoeller
 * @author Rob Harrop
 * @since 19.03.2004
 * @see ConfigurableListableBeanFactory#getBeanDefinition
 * @see org.springframework.beans.factory.support.RootBeanDefinition
 * @see org.springframework.beans.factory.support.ChildBeanDefinition
 */
public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {

	/**
	 * Specify the bean class name of this bean definition.
	 * <p>The class name can be modified during bean factory post-processing,
	 * typically replacing the original class name with a parsed variant of it.
	 * @see #setParentName
	 * @see #setFactoryBeanName
	 * @see #setFactoryMethodName
	 */
	void setBeanClassName(@Nullable String beanClassName);

	/**
	 * Override the target scope of this bean, specifying a new scope name.
	 * @see #SCOPE_SINGLETON
	 * @see #SCOPE_PROTOTYPE
	 */
	void setScope(@Nullable String scope);
    
    /**
	 * Set whether this bean should be lazily initialized.
	 * <p>If {@code false}, the bean will get instantiated on startup by bean
	 * factories that perform eager initialization of singletons.
	 */
	void setLazyInit(boolean lazyInit);

}

2、命名 Spring Bean 

Spring Bean的基本概念

 3、注册 Spring Bean

Spring Bean的基本概念

4、初始化 Spring Bean 

Spring Bean的基本概念

5、延迟初始化 Spring Bean

Spring Bean的基本概念 

6、实例化 Spring Bean

Spring Bean的基本概念

 7、销毁 Spring Bean

Spring Bean的基本概念

 

上一篇:springmvc学习指南 之---第31篇 使用墨客进行测试报错


下一篇:【DB笔试面试491】如何判断一个存储过程是否正在运行?