BeanUtils.copyProperties()的一个坑

spring的这个工具有个大坑:

 

 

   @Test
    public void test2() {
       List<A> list = new ArrayList<>(); //com.sentinel.demo.kk.A;
       list.add(new A("kk.A"));
       User user = new User();
       user.setList(list);
        User2 user2 = new User2();
        BeanUtils.copyProperties(user,user2); //执行完这一步不会报错,并且user2的List<A>有数据
        System.out.println(user2.getList().get(0).getClass()); //执行完这里就挂了


    }

 

posted @ 2022-03-11 17:48  yangxiaohui227  阅读(61)  评论(0)    收藏  举报