IoC

LXang7232024-04-09SpringBoot

Spring Framework Documentation

spring-framework 文档open in new window

spring-boot 文档open in new window

This chapter covers Spring’s Inversion of Control (IoC) container.

DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
reader.loadBeanDefinitions(new FileSystemResource("beans.xml"));

// bring in some property values from a Properties file
PropertySourcesPlaceholderConfigurer cfg = new PropertySourcesPlaceholderConfigurer();
cfg.setLocation(new FileSystemResource("jdbc.properties"));

// now actually do the replacement
cfg.postProcessBeanFactory(factory);
最后更新时间 2/14/2025, 5:53:56 AM