1:BeanUtils.copyProperties方法進行對象之間屬性的賦值,避免通過get、set方法一個一個屬性的賦值
public class BeanUtilsTest {
public static void main(String[] args) {
student student = new student("william","123");
User user = new User();
BeanUtils.copyProperties(student,user);
System.out.println(user.toString());
}
}
@Data
@AllArgsConstructor
class student{
private String name;
private String password;
}
@Data
class User{
private String name;
private String password;
}