我是春天的新手
这是bean注册的代码:
这是我的bean类:
public class User_Imple implements Master_interface {
private int id;
private User user; // here user is another class
public User_Imple() {
super();
}
public User_Imple(int id,User user) {
super();
this.id = id;
this.user = user;
}
// some extra functions here....
}
这是我执行操作的主要方法:
public static void main(String arg[]) {
ApplicationContext context = new ClassPathXmlApplicationContext("/bean.xml");
Master_interface master = (Master_interface)context.getBean("user");
// here is my some operations..
int id = ...
User user = ...
// here is where i want to get a Spring bean
User_Imple userImpl; //want Spring-managed bean created with above params
}
现在我想使用参数调用这个构造函数,这些参数是在我的main方法中动态生成的.这就是我想要传递的动态 – 不是静态的,就像在我的bean.config文件中声明的那样.