[答傻姑]如何在运行时添加spring的Bean?

02:25下午 六月 24, 2008 in category General by nile black

FileSystemXmlApplicationContext app = new FileSystemXmlApplicationContext();

app.refresh();

DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) app

.getBeanFactory();

beanFactory.registerBeanDefinition("string", BeanDefinitionBuilder

.rootBeanDefinition(String.class).getBeanDefinition());

System.out.println(app.containsBean("string"));

System.out.println(app.getBean("string"));

Comments[0]

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed