私は春が初めてです。
これは、Bean 登録のコードです。
<bean id="user" class="User_Imple"> </bean>
<bean id="userdeff" class="User"> </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
}
ここで、このコンストラクターをパラメーターで呼び出したいと思います。これらのパラメーターは、メイン メソッドで動的に生成されます。bean.config
これが、ファイルで宣言されているように静的ではなく、動的に渡したいという意味です。