getBean方法源码分析
parent
c802530dfd
commit
ff3faa04b6
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,7 @@
|
||||||
package com.xcs.spring;
|
package com.xcs.spring;
|
||||||
|
|
||||||
import com.xcs.spring.config.MyConfiguration;
|
import com.xcs.spring.config.MyConfiguration;
|
||||||
|
import com.xcs.spring.service.MyServiceA;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,9 +12,7 @@ public class GetBeanApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfiguration.class);
|
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfiguration.class);
|
||||||
for (String beanDefinitionName : context.getBeanDefinitionNames()) {
|
System.out.println("myServiceA = " + context.getBean("myServiceA"));
|
||||||
System.out.println("Bean = " + context.getBean(beanDefinitionName));
|
System.out.println("myServiceB = " + context.getBean("myServiceB"));
|
||||||
}
|
|
||||||
context.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue