本文整理了Java中org.springframework.context.annotation.AnnotationConfigApplicationContext.getBeanNamesForType()
方法的一些代码示例,展示了AnnotationConfigApplicationContext.getBeanNamesForType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AnnotationConfigApplicationContext.getBeanNamesForType()
方法的具体详情如下:
包路径:org.springframework.context.annotation.AnnotationConfigApplicationContext
类名称:AnnotationConfigApplicationContext
方法名:getBeanNamesForType
暂无
代码示例来源:origin: spring-projects/spring-framework
/**
* Test that values supplied to @Configuration(value="...") are propagated as the
* bean name for the configuration class even in the case of inclusion via @Import
* or in the case of automatic registration via nesting
*/
@Test
public void reproSpr9023() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(B.class);
ctx.refresh();
System.out.println(ctx.getBeanFactory());
assertThat(ctx.getBeanNamesForType(B.class)[0], is("config-b"));
assertThat(ctx.getBeanNamesForType(A.class)[0], is("config-a"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void individualBeanWithNullReturningSupplier() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.registerBean("a", BeanA.class, () -> null);
context.registerBean("b", BeanB.class, BeanB::new);
context.registerBean("c", BeanC.class, BeanC::new);
context.refresh();
assertTrue(ObjectUtils.containsElement(context.getBeanNamesForType(BeanA.class), "a"));
assertTrue(ObjectUtils.containsElement(context.getBeanNamesForType(BeanB.class), "b"));
assertTrue(ObjectUtils.containsElement(context.getBeanNamesForType(BeanC.class), "c"));
assertTrue(context.getBeansOfType(BeanA.class).isEmpty());
assertSame(context.getBean(BeanB.class), context.getBeansOfType(BeanB.class).values().iterator().next());
assertSame(context.getBean(BeanC.class), context.getBeansOfType(BeanC.class).values().iterator().next());
}
代码示例来源:origin: domix/jade4j-spring-boot-starter
@Test
@Ignore
public void renderNonWebAppTemplate() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
Jade4JAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
assertEquals(0, context.getBeanNamesForType(ViewResolver.class).length);
try {
JadeConfiguration engine = this.context.getBean(JadeConfiguration.class);
JadeTemplate template = engine.getTemplate("demo.jade");
Map<String, Object> params = params();
String result = engine.renderTemplate(template, params);
assertThat(result, containsString("With user"));
} finally {
context.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!