miller
发布于

BeanUtils.copyProperties null也会覆盖 复制过去

   @Test
    void qin() {
        Sconfig config = new Sconfig();
        config.setAge(1);
        config.setPasswd(null);
        config.setName("123");
        Sconfig target = new Sconfig();
        target.setPasswd("");
        System.out.println(target.getPasswd());

        BeanUtils.copyProperties(config,target);
        System.out.println(target.getPasswd());
    }

    @Data
    static class Sconfig{
        private String name;
        private int age;
        private String passwd;
    }
浏览 (261)
点赞
收藏
评论