ラム時に動的な値を必要とするコンストラクターがあり、
依存性注入を引き続き使用できるかどうか疑問に思っていました。この場合、Spring を使用して依存性注入を行う方法を教えてください。
public class User {
private String username;
private int userid;
User(String username, int userid) {
this.username = username;
this.userid = userid;
}
public String toString() {
return "username" + userid;
}
}
public class Superuser {
private User user;
public daomethod() {
//some data access code that gets the username and id ......
// now i need to pass this username and user id to the User constructor
user.toString();**
}
}