1、反射
public ClassPathXmlBeanFactory() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
String u="com.spring.UserDaoImpl";
Object uo=Class.forName(u).newInstance();
beanMaps.put("u",uo);
String s="com.spring.UserService";
Object so=Class.forName(s).newInstance();
String methodStr="setUserDao";
Method method=so.getClass().getMethod(methodStr,UserDao.class);//方法名和形参
method.invoke(so,uo);
beanMaps.put("s",so);
}