1. Bean-conf.properties File Contents:
Hello.class=com.yinbodotcc.hello
Hello.chars=zzz
The first line here represents an instance of the Com.yinbodotcc.Hello class Hello produced,
The second line here indicates that the chars property of this Hello object is set to ZZZ
2. Call Method:
Package COM.YINBODOTCC;
Import Org.springframework.core.io.FileSystemResource;
Import Org.springframework.beans.factory.BeanFactory;
Import Org.springframework.beans.factory.support.DefaultListableBeanFactory;
Import Org.springframework.beans.factory.support.BeanDefinitionRegistry;
Import Org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;
Public class Springdemo {
public static void Main (String args[])
{
Beandefinitionregistry reg= New Defaultlistablebeanfactory ();
propertiesbeandefinitionreader reader=new Propertiesbeandefinitionreader (reg);
reader.loadbeandefinitions (New Filesystemresource ("Bean-conf.properties"));
beanfactory bf= (beanfactory) reg;
isayhi isay= (Hello) bf.getbean ("Hello");
isay.sayhi ();
}
}