You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.1 KiB
29 lines
1.1 KiB
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);
|
|
}
|
|
}
|