import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Hello { public static void main(String[] args) { ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml"); String username = System.getenv("USERNAME"); System.out.println(username); Hello hello = ac.getBean(Hello.class); System.out.println(hello); String a = ac.getEnvironment().getProperty("a"); System.out.println(a); } } class MyBeanFactoryPostProcess implements BeanFactoryPostProcessor{ @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { BeanDefinition hello = beanFactory.getBeanDefinition("Hello"); // hello.set System.out.println(12); } }