Spring 使用 @Configuration配置, @Atowired 拿 bean 为null
Spring会完成Bean的扫描、注册和管理,但前提条件是Spring自身要启动起来。因此,你需要使用ApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfig.class)来启动Spring,Spring在启动过程中会扫描各种配置,并完成Bean的注册和初始化。当Spring启动之后,你就可以通过getBean方法拿到想要的Bean了。