import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import com.ceshi.bean.PersonBean;
import com.ceshi.demo.MyFilterType;
//配置类==配置文件(xml)
@Configuration //告诉Spring这个一个配制类
public class BeanConfig2 {
/**
* Specifies the name of the scope to use for the annotated component/bean.
* <p>Defaults to an empty string ({@code ""}) which implies
* {@link ConfigurableBeanFactory#SCOPE_SINGLETON SCOPE_SINGLETON}.
* @since 4.2
* @see ConfigurableBeanFactory#SCOPE_PROTOTYPE
* @see ConfigurableBeanFactory#SCOPE_SINGLETON
* @see org.springframework.web.context.WebApplicationContext#SCOPE_REQUEST
* @see org.springframework.web.context.WebApplicationContext#SCOPE_SESSION
* @see #value
* singleton:单例
* prototype:多实例
* request:同一次请求创建一个实例
* session:同一个session会话创建一个实例
*
* 懒加载:
* 单例bean:默认在容器启动的时候创建,
* 懒加载:容器启动的时候不创建,使用的时候创建。并初始化
*
*/
@Lazy
//给容器注册一个Bean,类型class:默认为返回值的类型,标识id:默认为方法名
@Bean("person")
public PersonBean personBean(){
return new PersonBean("lishi","20");
}
}