public class UserFactoryBean implements FactoryBean<User04> {
@Override
public User04 getObject() throws Exception {
// TODO Auto-generated method stub
System.out.println("UserFactoryBean...getObject...");
return new User04("User04");
}
@Override
public Class<?> getObjectType() {
// TODO Auto-generated method stub
return User04.class;
}
//是否单例?
//true:这个bean是单实例,在容器中保存一份
//false:多实例,每次获取都会创建一个新的bean;
@Override
public boolean isSingleton() {
// TODO Auto-generated method stub
return true;
}
}
public class User04 {
public String username;
public User04(String s) {
String nowtime= DateUtil.now();
username=s+" "+nowtime;
}
}
@Configuration
@Import({ImportDemo.class, MyImportSelector.class, MyImportBeanDefinitionRegistrar.class})
public class ImportConfig {