The normal way without IOC containers would be:
new User("Names", 22);
where the parameter values here are dynamic, whereby, for example, they are fetched via a user submission form, thereby can't be stored in a file.
TextField userNames = new TextField();
names = userNames.getText()
same for the other parameters.
where:
@Component
public class User {
public User(String names, int age) {
.
.
.
}
}
How do I initialize User
, while passing the constructor's parameters, where User is Autowired
into another class:
@Component
public class AnotherClass {
@Autowired
User user(....)????? // How do I do it here
.
.
.
}