java版toModel
- private static <T, S> T toModel(S source, Class clazz) {
- long startTime = System.currentTimeMillis();
- try {
- Object obj = clazz.newInstance();
- BeanUtils.copyProperties(source, obj);
- long endTime = System.currentTimeMillis();
- System.out.println("程序运行时间:" +Float.toString((endTime - startTime))+"ms");
- return (T) obj;
- } catch (IllegalAccessException e1) {
- } catch (InstantiationException e2) {
- }
- return null;
- }
============ 欢迎各位老板打赏~ ===========
与本文相关的文章
- · Java基础问题13个,你都会哪些?
- · 不重新打包项目并替换部分jar包
- · 接收企微事件回调 Content type ‘text/xml;charset=UTF-8’ not supported
- · springboot使用lock4j实现并发控制
- · springboot全局增加sentinel
- · linux快速搭建轻量级efk日志系统
- · Springboot整合Swagger常用注解
- · swagger隐藏authentication参数
- · Spring Security 中的自定义PreAuthorize 注解
- · Expected one result (or null) to be returned by selectOne(), but found: 2
- · JACKSON和FASTJSON处理返回JSON数据中为NULL字段不显示
- · mybatis报错 : Caused by: java.lang.IllegalStateException: Can not find owner from table.