Answer the question
In order to leave comments, you need to log in
How to correctly configure List in spring.xml?
I get acquainted with the spring, I don’t understand why it swears in my case?
user.class
public class User {
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUsedId() {
return usedId;
}
public void setUsedId(String usedId) {
this.usedId = usedId;
}
public List<Address> getAddress() {
return addresses;
}
public void setAddress(Address address) {
this.addresses.add(address);
}
public List<Message> getMessage() {
return messages;
}
public void setMessage(Message message) {
this.messages.add(message);
}
@Override
public String toString() {
return "User{" +
"firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", email='" + email + '\'' +
", usedId='" + usedId + '\'' +
", address=" + addresses +
", message=" + messages +
'}';
}
private String firstName;
private String lastName;
private String email;
private String usedId;
// One to Many relationship
private List<Address> addresses;
// One To Many relationship
private List<Message> messages;
}
Answer the question
In order to leave comments, you need to log in
According to the JavaBeans specification, Spring takes the name you give it, capitalizes the first letter, and prefixes it with set to use the setAdresses() method, which is missing in your case - the setter is named incorrectly. Either change get-, setAddress() to get-, setAddresses() or write adress instead of adresses in XML
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question