spring-api基础操作

@Autowired

		DefaultListableBeanFactory defaultListableBeanFactory = new DefaultListableBeanFactory();
         AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition().getBeanDefinition();
         definition.setBeanClass(ClueOrigin.class);
         defaultListableBeanFactory.registerBeanDefinition("a",definition);
         System.out.println(defaultListableBeanFactory.getBean("a"));

读取

 		AnnotationConfigApplicationContext configApplicationContext = new AnnotationConfigApplicationContext();
        AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(configApplicationContext);
        reader.register(ClueOrigin.class);
        configApplicationContext.refresh();
        System.out.println(configApplicationContext.getBean("clueOrigin"));
上一篇:Spring整合Mybatis源码解析:@MapperScan原理(二)


下一篇:html-list