User
import org.msgpack.annotation.Message;@Messagepublic class User { private String id; private String userName; private int age; private UserContact userContact; public User(String userName, int age, String id) { this.userName = userName; this.age = age; this.id = id; } public User() { } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getId() { return id; } public void setId(String id) { this.id = id; } public UserContact getUserContact() { return userContact; } public void setUserContact(UserContact userContact) { this.userContact = userContact; } @Override public String toString() { return "User{" + "userName='" + userName + '\'' + ", age=" + age + ", id='" + id + '\'' + ", userContact=" + userContact + '}'; }}
UserContact
import org.msgpack.annotation.Message;@Message//MessagePack提供的注解,表明这是一个需要序列化的实体类public class UserContact { private String mail; private String phone; public UserContact() { } public UserContact(String mail, String phone) { this.mail = mail; this.phone = phone; } public String getMail() { return mail; } public void setMail(String mail) { this.mail = mail; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } @Override public String toString() { return "UserContact{" + "mail='" + mail + '\'' + ", phone='" + phone + '\'' + '}'; }}