1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
package demo.core1; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.stereotype.Component; /** * * @author 老唐 */ public class App { /** * * @author 老唐 */ @Component public static class Bean1 { public String getMsg() { return "你好"; } } public static void main(String[] argv) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext("demo.core1"); final Bean1 b1 = ctx.getBean(Bean1.class); System.out.print("b1.getMsg()" + b1.getMsg()); } } |