<bean id="hello" class="com.cloud.pojo.User">
<property name="userId" value="1"></property>
<property name="userType" value="2"></property>
<property name="userName" value="3"></property>
<property name="userPwd" value="4"></property>
</bean>
public class User {
private Integer userId;
private Integer userType;
private String userName;
private String userPwd;
@Override
public String toString() {
return "User{" +
"userId=" + userId +
", userType=" + userType +
", userName='" + userName + '\'' +
", userPwd='" + userPwd + '\'' +
", userPhone='" + userPhone + '\'' +
'}';
}
private String userPhone;
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getUserType() {
return userType;
}
public void setUserType(Integer userType) {
this.userType = userType;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName == null ? null : userName.trim();
}
public String getUserPwd() {
return userPwd;
}
public void setUserPwd(String userPwd) {
this.userPwd = userPwd == null ? null : userPwd.trim();
}
public String getUserPhone() {
return userPhone;
}
public void setUserPhone(String userPhone) {
this.userPhone = userPhone == null ? null : userPhone.trim();
}
}
ApplicationContext applicationContext=new ClassPathXmlApplicationContext("spring/applicationContext.xml");
User hello = (User)applicationContext.getBean("hello");
System.out.println(hello.toString());
输出
User{userId=1, userType=2, userName='3', userPwd='4', userPhone='null'}