import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
public class Main {
public static void main(String[] args) {
XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("context.xml"));
System.out.println(bf.getBean("target1"));
System.out.println(bf.getBean("target2"));
System.out.println(bf.getBean("target3"));
}
}
class SimpleBean {
private int someInt;
private SimpleBean nestedSimpleBean;
public void setSomeInt(int someInt) {
this.someInt = someInt;
}
public void setNestedSimpleBean(SimpleBean nestedSimpleBean) {
this.nestedSimpleBean = nestedSimpleBean;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("SimpleBean");
sb.append("{someInt=").append(someInt);
sb.append(", nestedSimpleBean=").append(nestedSimpleBean);
sb.append('}');
return sb.toString();
}
}
|