首页 > 其他分享 >org.springframework.beans.BeanUtils

org.springframework.beans.BeanUtils

时间:2023-10-09 14:13:03浏览次数:25  
标签:user1 System springframework declaredMethod beans org BeanUtils Hello out

 

        {//拷贝对象的属性
            Hello user1 = new Hello();
            user1.setId(1);
            user1.setName("name");

            Hello user2 = new Hello();
            BeanUtils.copyProperties(user1, user2);
            System.out.println(user2);
        }

        {//实例化某个类
            Hello user = BeanUtils.instantiateClass(Hello.class);//通过反射实例化一个类的对象
            System.out.println(user);
        }

        {//获取指定类的指定方法
            Method declaredMethod = BeanUtils.findDeclaredMethod(Hello.class, "getId");
            System.out.println(declaredMethod.getName());
        }

        {//获取指定方法的参数
            Method declaredMethod = BeanUtils.findDeclaredMethod(Hello.class, "getId");
            PropertyDescriptor propertyForMethod = BeanUtils.findPropertyForMethod(declaredMethod);
            System.out.println(propertyForMethod.getName());
        }

  

标签:user1,System,springframework,declaredMethod,beans,org,BeanUtils,Hello,out
From: https://www.cnblogs.com/ooo0/p/17751577.html

相关文章

  • org.springframework.util.ClassUtils
     {//获取对象的所有接口Class<?>[]allInterfaces=ClassUtils.getAllInterfaces(ClassUtils.class);System.out.println(allInterfaces[0].getName());}{//获取某个类的包名StringpackageName=ClassUt......
  • org.apache.commons.io.IOUtils
    IO流在我们日常工作中也用得比较多,尽管java已经给我们提供了丰富的API。但我们不得不每次读取文件,或者写入文件之后,写一些重复的的代码。手动在finally代码块中关闭流,不然可能会造成内存溢出。有个好消息是:如果你使用org.apache.commons.io包下的IOUtils类,会节省大量的时间。 ......
  • org.apache.commons.lang3.BooleanUtils
      {//判断true或falseBooleanaBoolean=newBoolean(true);System.out.println(BooleanUtils.isTrue(aBoolean));System.out.println(BooleanUtils.isFalse(aBoolean));}{//判断不为true或不为false......
  • org.apache.commons.collections4.CollectionUtils
      {//集合判空List<Integer>list=newArrayList<>();list.add(2);list.add(1);list.add(3);if(CollectionUtils.isEmpty(list)){System.out.println("集合为......
  • 安全工具合集:125个最佳网络安全工具-SecToolsOrg
    SecToolsOrg是什么SecToolsOrg是一个国外网友创建的安全工具网站,收集了125个最佳网络安全工具,网站为英文语言,网站提供评级、评论、搜索、排序和新工具建议表,该站点允许在任何平台上使用开源和商业工具,每款软件工具都有详细的介绍截图等等,感兴趣的同学可以到网站学习。英文页面......
  • idea报错:Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (d
    idea版本:​​2020.3​​idea报错:在查阅了资料以后发现是​​IDEA2020​​的兼容问题 Failedtoexecutegoalorg.codehaus.mojo:exec-maven-plugin:3.0.0:exec(default-cli)onprojectsms:Commandexecutionfailed.解决方法:1、测试不要用​​main​​方法测试,使用​​......
  • Exception in thread "main" java.lang.UnsupportedClassVersionError: org/example/J
    问题描述使用hadoop在虚拟机里面运行打包的程序出错:问题解决真的服了,貌似是jdk的版本啥的问题,搜了好多,就是解决不了,求助求助啊!......
  • 3. SpringMVC-使用注解开发-beans
    万能开头:<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xmlns:c="http://www.spring......
  • spring注解开发---beans注入
    万能xml开头:<!--导入p,c命名空间context注解--><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"......
  • beans头
    MVC全部导入的xml头<!--导入p,c命名空间context注解--><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p&qu......