标签:java star 总结 pre config loser ssm ons cto
@Import({HelloService.class})
public class AppConfig {
}
@Import({MyImport.class})
public class AppConfig {
}
public class MyImport implements ImportSelector {
public String[] selectImports(AnnotationMetadata annotationMetadata) {
return new String[]{"com.run.HelloService"};
}
}
@Import({MyImport.class})
public class AppConfig {
}
public class MyImport implements ImportBeanDefinitionRegistrar {
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
//指定bean定义信息(包括bean的类型、作用域...)
RootBeanDefinition rootBeanDefinition=new RootBeanDefinition(HelloService.class);
//注册一个bean指定bean名字(id)
registry.registerBeanDefinition("TestDemo4444",rootBeanDefinition);
}
}
标签:java star 总结 pre config loser ssm ons cto
原文地址:https://www.cnblogs.com/yinchh/p/13073217.html