动态添加字段和注解,形成class类,集合对象动态创建Excel列

news2025/10/26 3:08:11

一.需求

      动态生成Excel列,因为Excel列是通过类对象字段注解来添加,在不确定Excel列数的情况下,就需要动态生成列,对应类对象字段也需要动态生成;

二.ByteBuddy字节码增强动态创建类

1.依赖

<dependencies>
  <dependency>
    <groupId>net.bytebuddy</groupId>
    <artifactId>byte-buddy</artifactId>
    <version>1.11.17</version>
  </dependency>
</dependencies>

2.动态创建类

public  Class<? extends ExcelRecordDynamicDTO> getDynamicClass(ChatBatchRequestVO chatBatchRequest) throws NoSuchFieldException, IllegalAccessException, InstantiationException {
        DynamicType.Builder<ExcelRecordDynamicDTO> dynamicClass = new ByteBuddy()
                .subclass(ExcelRecordDynamicDTO.class);
        dynamicClass = dynamicClass.defineField("question", String.class, Visibility.PUBLIC)
                .annotateField(AnnotationDescription.Builder.ofType(ExcelColumn.class)
                        .define("value", new String("问题"))
                        .define("col", 1)
                        .build())
                .defineMethod("getQuestion", String.class, Visibility.PUBLIC)
                .intercept(FieldAccessor.ofBeanProperty())
                .defineMethod("setQuestion", void.class, Visibility.PUBLIC)
                .withParameters(String.class)
                .intercept(FieldAccessor.ofBeanProperty());
        for (int i = 0; i < chatBatchRequest.getModelTypeId().length; i++) {
            dynamicClass = dynamicClass.defineField("answer" + i, String.class, Visibility.PUBLIC)
                    .annotateField(AnnotationDescription.Builder.ofType(ExcelColumn.class)
                            .define("value", new String(ChatModelTypeEnum.getmodelShowNameByType(chatBatchRequest.getModelTypeId()[i])))
                            .define("col", i + 2)
                    .build())
                    .defineMethod("getAnswer" + i, String.class, Visibility.PUBLIC)
                    .intercept(FieldAccessor.ofBeanProperty())
                    .defineMethod("setAnswer" + i, void.class, Visibility.PUBLIC)
                    .withParameters(String.class)
                    .intercept(FieldAccessor.ofBeanProperty());
        }
        Class<? extends ExcelRecordDynamicDTO> d = dynamicClass.make().load(ExcelRecordDynamicDTO.class.getClassLoader()).getLoaded();
        return d;
    }


​动态类如下所示:
public class ExcelRecordDynamicDTO implements Serializable {

      //动态生成的字段和注解如下所示
      //@ExcelColum(value="第一列", col=1)
      //private String col1;
}

​


3.实例化赋值

//实例化
Class<? extends ExcelRecordDynamicDTO> dy = getDynamicClass(chatBatchRequest);
ExcelRecordDynamicDTO dtp = dy.newInstatnce();

//赋值
Field[] cityCode = dto.getClass().getDeclaredFields();
for (Filed f : cityCode) {
    f.setAccessible(true)
    f.set(dto, "赋值");
}

//获取值
dto.getClass().getDeclaredField("question").get(dto)

 4.创建Excel

List<ExcelRecordDynamicDTO> resultList = new ArrayList<>();
resultList.add(dto);

ExcelUtil.writeExcel(resultList,dy.newInstance());

三.Excel工具类

                   

1.依赖

<dependencies>
  <dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.13</version>
  </dependency>

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.13</version>
  </dependency>
</dependencies>

2.Excel代码

注解如下:
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ExcelColumn {

   //标题
   String value() default "";
  
   //Excel从左往右排列位置
   int col() default 0;
}
Excel工具类:使用apache.poi
public class ExcelUtil {
    private final static String EXCEL2003 = "xls";
    private final static EXCEL2007 = "xlsx";
  
    public static <T> List<T> readExcel(String path, Class<T> cls, File file) {
        String fileName = file.getName();
        if (!fileName.matches("^.+\\.)?i)(xls)$") && !fineName.matches("^.+\\.(?i)(xlsx)$")) {
              log.error("格式错误");
         }
         List<T> dataList = new ArrayList<>();
         Workbook workbook = null;
         try {
            
              if (fileName.endsWith(EXCEL2007)) {
                  InputStream is = new FileInputStream(new File(path));
                  workbook = new XSSFWorkbook(is);
              }
              if (fileName.endsWith(EXCEL2003)) {
                  InputStream is = new FileInputStream(new File(path));
                  workbook = new HSSFWorkbook(is);
              } 
              if (workbook != null ) {
                  Map<String, List<Field>> classMap = new HashMap<>();
                  List<Field> fields = Stream.of(cls.getDeclaredFields()).collectors.toList());
                  fields.forEach(field -> {
                       ExcelColumn annotaion = field.getAnnotation(ExcelColum.class);
                       if (annotaion != null) {
                           String value = annotation.value();
                           if (StringUtils.isBlank(value)) {
                              return;
                           }
                           if (!classMap.containsKey(value)) {
                               classMap.put(value, new ArrayList<>());
                           }
                           field.setAccessible(true);
                           classMap.get(value).add(field);
                       }
                   });
                   //索引---columns
                   Map<Integer, List<Field>> refectionMap = new HashMap<>(16);
                   //默认读取第一个sheet
                   Sheet sheet = workbook.getSheetAt(0);
                   booleasn firstRow = true;
                   for (int i = sheet.getFirstRowNum(); i <= sheet.getLastRowNum(); i++) 
                  {
                     Row row = sheet.getRow(i);
                     //首行 提取注解
                     if (firstRow) {
                         for (int j = row.getFirstCellNum(); j <= row.getLastCellNum();         
                     j++) {
                           Cell cell = row.getCell(j);
                           String cellValue = getCellValue(cell);
                           if (classMap.containsKey(cellValue) {
                               reflectionMap.put(j, classMap.get(cellValue));
                             }
                           }
                          firstRow false;
                          } else {
                            //忽略空白行
                            if (row == null) {
                                continue;
                             }
                             try {
                             T t = cls.newInstance();
                             //判断是否为空白行
                              boolean allBlank = true;
                              for (int j = row.getFirstCellNum(); j <= 
                               row.getLastCellNum(); j++) {
                                  if (reflectionMap.containsKey(j)) {
                                   Cell cell = row.getCell(j);
                                   String cellValue = getCellValue(cell);
                                   if (StringUtils.isNotBlank(cellValue)) {
                                       allBlank = false;
                                      }
                                    List<Field> fieldList = reflectionMap.get(j);
                                    fieldList.foeEach(x -> {
                                       try {
                                         handleField(t, cellValue, x);
                                       } catch (Exception e) {
                                          log.error(e);
                                        }
                                    });
                                    }
                               }
                                  if (!allBlank) {
                                      dataList.add(t);
 
                                  } else {
                                     log.warn("ignore!");
                                  }                                                                                    
                             } catch (Exception e) {
                                log.error(e);
                              }
                           }

                   }
              }
         } catch (Exception e) {
             log.error(e);
         } finally {
            if (workbook != null) {
               try {
                 workbook.close();
               } catch (Exception e) {
                 log.error(e);
               }
            }
         }
         return dataList;
    }

public static <T> List<T> readExcel(Class<T> cls, MultipartFile file) {
        String fileName = file.getOriginalFilename();
        if (!fileName.matches("^.+\\.)?i)(xls)$") && !fineName.matches("^.+\\.(?i)(xlsx)$")) {
              log.error("格式错误");
         }
         List<T> dataList = new ArrayList<>();
         Workbook workbook = null;
         try {
              InputStream is = file.getInputStream();
              if (fileName.endsWith(EXCEL2007)) {
                  workbook = new XSSFWorkbook(is);
              }
              if (fileName.endsWith(EXCEL2003)) {
                  workbook = new HSSFWorkbook(is);
              } 
              if (workbook != null ) {
                  Map<String, List<Field>> classMap = new HashMap<>();
                  List<Field> fields = Stream.of(cls.getDeclaredFields()).collectors.toList());
                  fields.forEach(field -> {
                       ExcelColumn annotaion = field.getAnnotation(ExcelColum.class);
                       if (annotaion != null) {
                           String value = annotation.value();
                           if (StringUtils.isBlank(value)) {
                              return;
                           }
                           if (!classMap.containsKey(value)) {
                               classMap.put(value, new ArrayList<>());
                           }
                           field.setAccessible(true);
                           classMap.get(value).add(field);
                       }
                   });
                   //索引---columns
                   Map<Integer, List<Field>> refectionMap = new HashMap<>(16);
                   //默认读取第一个sheet
                   Sheet sheet = workbook.getSheetAt(0);
                   booleasn firstRow = true;
                   for (int i = sheet.getFirstRowNum(); i <= sheet.getLastRowNum(); i++) 
                  {
                     Row row = sheet.getRow(i);
                     //首行 提取注解
                     if (firstRow) {
                         for (int j = row.getFirstCellNum(); j <= row.getLastCellNum();         
                     j++) {
                           Cell cell = row.getCell(j);
                           String cellValue = getCellValue(cell);
                           if (classMap.containsKey(cellValue) {
                               reflectionMap.put(j, classMap.get(cellValue));
                             }
                           }
                          firstRow false;
                          } else {
                            //忽略空白行
                            if (row == null) {
                                continue;
                             }
                             try {
                             T t = cls.newInstance();
                             //判断是否为空白行
                              boolean allBlank = true;
                              for (int j = row.getFirstCellNum(); j <= 
                               row.getLastCellNum(); j++) {
                                  if (reflectionMap.containsKey(j)) {
                                   Cell cell = row.getCell(j);
                                   String cellValue = getCellValue(cell);
                                   if (StringUtils.isNotBlank(cellValue)) {
                                       allBlank = false;
                                      }
                                    List<Field> fieldList = reflectionMap.get(j);
                                    fieldList.foeEach(x -> {
                                       try {
                                         handleField(t, cellValue, x);
                                       } catch (Exception e) {
                                          log.error(e);
                                        }
                                    });
                                    }
                               }
                                  if (!allBlank) {
                                      dataList.add(t);
 
                                  } else {
                                     log.warn("ignore!");
                                  }                                                                                    
                             } catch (Exception e) {
                                log.error(e);
                              }
                           }

                   }
              }
         } catch (Exception e) {
             log.error(e);
         } finally {
            if (workbook != null) {
               try {
                 workbook.close();
               } catch (Exception e) {
                 log.error(e);
               }
            }
         }
         return dataList;
    }

    private static <T> void handleField(T t, String value, Field field) trows Exception 
    {
      Class<?> type = field.getType();
      if (type == null || type== void.class || StringUtils.isBlank(value)) {
          return;
       }
       if (type == Object.class) {
           field.set(t, value);
       } else if (type.getSuperclass() == null || type.getSuperclass() == Number.calss) 
       {
          if (type == int.class || type == Integer.class) {
            field.set(t, NumberUtils.toInt(value));
           } else if (type == long.class || type == Long.calss ) {
            field.set(t, NumberUtils.toLong(value));
           } else if (type == byte.class || type == Byte.calss ) {
            field.set(t, NumberUtils.toByte(value));
           } else if (type == short.class || type == Short.calss ) {
            field.set(t, NumberUtils.toShort(value));
           } else if (type == double.class || type == Double.calss ) {
            field.set(t, NumberUtils.toDouble(value));
           } else if (type == float.class || type == Float.calss ) {
            field.set(t, NumberUtils.toFloat(value));
           } else if (type == char.class || type == Character.calss ) {
            field.set(t, NumberUtils.toChar(value));
           } else if (type == boolean.class) {
            field.set(t, NumberUtils.toBoolean(value));
           } else if (type == BigDecimal.class) {
            field.set(t, new BigDecimal(value));
           }
        } else if (type == Boolean.class) {
           field.set(t, BooleanUtils.toBoolean(value));
        } else if (type == Data.class) {
           SimpleDateFprmat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
           field.set(t, format.parse(value));
        } else if (type == String.class) {
           field.set(t, value);
        } else {
           Constructor<?> constructor = type.getConstructor(String.class);
           field.set(t, constructor .newInstance(value));
        }
     }

  private static String getCellValue(Cell cell) {
      if (cell == null) {
          return "";
      }
      if (cell.getCellType() == Cell CELL_TYPE_NUMERIC) {
         if (HSSFDateUtil.isCellDateFormatted(cell)) {
             return HSSDateUtil.getJavaDate(cell.getNumericCellValue()).toString();
         }
         else {
             return new BigDecimal(cell.getNumericCellValue()).toString();
         }
      } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
              return StringUtils.trimToEmpty(cell.getStringCellValue());
      }  else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
              return StringUtils.trimToEmpty(cell.getCellFormula());
      }  else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) {
              return "";
      }  else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
              return StringUtils.trimToEmpty(cell.getBooleanCellValue());
      }  else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) {
              return "ERROR";
      } else  {
              return cell.toString().trim;
      }
  }

  public static <T> void writeExcel(String filePathName, List<T> dataList, ExcelRecordDynamicDTO excelRecordDTO) {
        Field[] fields = excelRecordDTO.getClass().getDeclaredFields();
        List<Field> fieldList = Arrays.stream(fields).filter(field -> {
            ExcelColumn annotaion = field.getAnnoation(ExcelColum.class);
            if (annotation != null && annotation.col() > 0) {
                field.setAccessible(true);
                return true;
            }
            return false;
        }).sorted(Comparator.comparing(field -> {
            int col = 0;
            ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
            if (annotation != null) {
                 col = annotation.col();
            }
            return col;
         })).collect(Collectors.toList());
         Workbook wb = new XSSFWorkbook();
         Sheet sheet = wb.createSheet("Sheet1");
         AtomicInteger ai = new AtomicInteger();
         {
            Row row = sheet.createRow(ai.getAndIncrement());
            AtomicInteger aj = new AtomicInteger();
            //写入头部
            fieldList.forEach(field -> {
                ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
                String columnName = "";
                if (annotation != null) {
                   columnName = annotation.value();
                }
                Cell cell = row.createCell(aj.getAndIncreament());
                CellStyle cellStyle = wb.createCellStyle();
                cellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
                cellSty;e.setFillPattern(CellStyle.SOLID_FOREGROUND);
                cellSty;e.setAlignment(CellStyle.ALIGN_CENTER);

                Font font = wb.createFont();
                font.setBoldweight(Font.BOLDWEIGHT_NORMAL);
                cellStyle.setFont(font);
                cell.setCellStyle(cellStyle);
                cell.setCellValue(columnName);
            });
         }
         if (CollectionUtils.isNatEmpty(dataList)) {
            dataList.forEach(t -> {
                Row row1 = sheet.createRow(ai.getAndIncrement());
                AtomicInteger aj = new AtomicInteger();
                fieldList.forEach(field -> {
                    Class<?> type = field.getType();
                    Object value = "";
                    try {
                       value = field.get(t);
                    } catch (Exception e) {
                       e.printStackTrace();
                    }
                    Cell cell = row1.createCell(aj.getAndIncrement());
                    if (value != null) {
                        if (type == Date.class) {
                            cell.setCellValue(value.toString());
                        } else {
                            cell.setCellValue(value.toString());
                        }
                        cell.setCellValue(value.toString());
                    }
                });
            });
         }
         //冻结窗格
         wb.getSheet("Sheet1").createFreezePane(0, 1, 0, 1);
         //浏览器下载excel
         //buildExcelDocument("abbot.xlsx", wb, response);
         //生成Excel文件
         buildExcelFile(filePathName, wb);
  } 
  
  private static void buildExcelFile(String path, Workbook wb) {
       File file = new File(path);
       if (file.exists()) {
          file.delete();
        }
       try {
         wb.write(newFileOutputStream(file));
       } catch (Exception e) {
         e.printStackTrace();
       }
  }

}

四.附

使用ClassPool动态生成类,实测暂未解决的问题:

1.无法给字段注解属性为int类型的赋值;

2.只能一次创建,无法清除上次动态创建的字段

代码如下:

 <dependency>
     <groupId>javassist</groupId>
     <artifactId>javassist</artifactId>
     <version>3.12.1.GA</version>
 </dependency>
public Object getExcelRecordDynamicClass(ChatBatchRequestVO chatBatchRequest) throws NotFoundException, CannotCompileException, IllegalAccessException, InstantiationException {
        //默认的类搜索路径
        ClassPool pool = ClassPool.getDefault();
        //获取一个ctClass对象 com.example.demo.excel.entity.CitiesVo 这个是包的相对路径
//        CtClass ctClass = pool.makeClass("ExcelRecordDynamicDTO");
        CtClass ctClass = pool.get("cn.com.wind.ai.platform.aigc.test.pojo.excel.ExcelRecordDynamicDTO");
        for (int i = 0; i < chatBatchRequest.getModelTypeId().length; i++) {
            //添加属性
            ctClass.addField(CtField.make("public String answer"+ i +";", ctClass));
            //添加set方法
            ctClass.addMethod(CtMethod.make("public void setAnswer"+ i +"(String answer"+ i +"){this.answer"+ i +" = answer"+ i +";}", ctClass));
            //添加get方法
            ctClass.addMethod(CtMethod.make("public String getAnswer"+ i +"(){return this.answer"+ i +";}", ctClass));
            //获取这个字段
            CtField answer = ctClass.getField("answer"+ i);
            FieldInfo fieldInfo = answer.getFieldInfo();
            ConstPool cp = fieldInfo.getConstPool();
            AnnotationsAttribute attribute = (AnnotationsAttribute) fieldInfo.getAttribute(AnnotationsAttribute.visibleTag);
            //这里进行了判断 如果说当前字段没有注解的时候 AnnotationsAttribute 这个对象是为空的
            //所以要针对这个进行新创建 一个 AnnotationsAttribute 对象
            if(ObjectUtils.isEmpty(attribute)){
                List<AttributeInfo> attributeInfos =fieldInfo.getAttributes();
                attribute = !attributeInfos.isEmpty()?(AnnotationsAttribute) attributeInfos.get(0):
                        new AnnotationsAttribute(fieldInfo.getConstPool(), AnnotationsAttribute.visibleTag);
            }
            // Annotation 默认构造方法  typeName:表示的是注解的路径
            Annotation bodyAnnot = new Annotation("cn.com.wind.ai.platform.aigc.test.framework.aop.excel.ExcelColumn", cp);
            // name 表示的是自定义注解的 方法  new StringMemberValue("名字", cp) 表示给name赋值
            bodyAnnot.addMemberValue("value", new StringMemberValue(ChatModelTypeEnum.getmodelShowNameByType(chatBatchRequest.getModelTypeId()[i]), cp));
//            IntegerMemberValue colValue = new IntegerMemberValue(i + 2, cp);
//            bodyAnnot.addMemberValue("col", colValue);
            attribute.addAnnotation(bodyAnnot);
            fieldInfo.addAttribute(attribute);
        }
        pool.clearImportedPackages();
        return ctClass.toClass().newInstance();
    }

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1411349.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

STM32标准库——(3)LED闪烁、LED流水灯、蜂鸣器

1.相关API 1.1 GPIOSpeed_TypeDef /** * brief Output Maximum frequency selection 最大频率选择*/typedef enum { GPIO_Speed_10MHz 1,GPIO_Speed_2MHz, GPIO_Speed_50MHz }GPIOSpeed_TypeDef;1.2 GPIOMode_TypeDef /** * brief Configuration Mode enumeration 配置…

C/C++ - Auto Reference

目录 auto Reference auto 当使用auto​​关键字声明变量时&#xff0c;C编译器会根据变量的初始化表达式推断出变量的类型。 自动类型推断&#xff1a;auto​​关键字用于自动推断变量的类型&#xff0c;使得变量的类型可以根据初始化表达式进行推导。 初始化表达式&#x…

2.依附弹窗(AttachListPopup)

愿你出走半生,归来仍是少年&#xff01; 环境&#xff1a;.NET 7 基于基础的Popup对象实现的依附于某个控件的弹窗&#xff0c;弹窗可呈现数组对象&#xff0c;达到较好的选择交互效果。 1.布局 通过Border实现圆角边框轮廓&#xff0c;然后通过内部的ListView实现列表展示。…

二叉树中的深度搜索

力扣2331.计算布尔二叉树值 深度搜索&#xff1a;是要进入最下面 二叉树直接往递归上去想&#xff08;易写&#xff0c;不易想&#xff09; public boolean evaluateTree(TreeNode root) {if(root.leftnull||root.rightnull){return root.val0?false:true;} //先拿到左子树&…

E4 基于Mysql的游标定义和应用

一、实验目的: 熟练使用MySQL游标的定义和应用。 二、实验要求: 1、基本硬件配置:英特尔Pentium III 以上,大于4G内存&#xff1b; 2、软件要求:Mysql&#xff1b; 3、时间:1小时&#xff1b; 4、撰写实验报告并按时提交。 三、实验内容: 问题1&#xff1a;请写一个存储…

虚拟机打开之后,无法响应

文章目录 前言一、虚拟机无法响应的前因后果二、解决办法1.找到安装的虚拟机的位置2.将上面的带.lck 的文件删除3. 重新启动虚拟机 总结 前言 虚拟机一直用的好好的&#xff0c;突然打开后无法响应&#xff0c;在此记录下解决的过程。 一、虚拟机无法响应的前因后果 1、虚拟机…

php二次开发股票系统代码:腾讯股票数据接口地址、批量获取股票信息、转换为腾讯接口指定的股票格式

1、腾讯股票数据控制器 <?php namespace app\index\controller;use think\Model; use think\Db;const BASE_URL http://aaaaaa.aaaaa.com; //腾讯数据地址class TencentStocks extends Home { //里面具体的方法 }2、请求接口返回内容 function juhecurl($url, $params f…

1174:长整数排序(指针专题)

题目描述 长整数排序。输入n 然后输入n个位数不超过100位的大整数&#xff0c;输入的整数可能含有前导0。将这n个长整数排序后输出&#xff0c;输出不含前导0。int greater(char *s1, char *s2){若s1指向的整数大于s2指向的整数&#xff0c;返回一个正整数;若s1指向的整数小于s…

baijia靶场漏洞挖掘

打开靶场http://localhost:83/baijiacms/ 1、任意用户注册 点击个人中心>用户登录>免费注册&#xff0c;注入账号密码&#xff0c;抓包 批量注册 这个是已注册的用户返回。 这个是未注册的用户&#xff0c;通过批量注册可以探测到系统已有用户 2、XSS漏洞 打开我的地址…

【linux】-telnet服务安装

1. 说明 telnet 分为 &#xff1a;telnet 服务端 和 telnet 客户端 本文只演示安装 telnet服务端 2. 安装telnet服务端、以及守护服务xinetd 2.1 检测telnet-server的rpm包是否安装 rpm -qa telnet-server 2.2 若未安装&#xff0c;则安装telnet-server&#xff0…

Oracal学习

Oracle是什么 是甲骨文公司的一款支持事务且吞吐量高的数据库特点&#xff1a; &#xff08;1&#xff09;支持多用户、大事务量的事务处理 &#xff08;2&#xff09;数据安全性和完整性控制 &#xff08;3&#xff09;支持分布式数据处理 &#xff08;4&#xff09;可移植性…

WEB安全渗透测试-pikachuDVWAsqli-labsupload-labsxss-labs靶场搭建(超详细)

目录 phpstudy下载安装 一&#xff0c;pikachu靶场搭建 1.下载pikachu 2.新建一个名为pikachu的数据库 3.pikachu数据库配置 ​编辑 4.创建网站 ​编辑 5.打开网站 6.初始化安装 二&#xff0c;DVWA靶场搭建 1.下载DVWA 2.创建一个名为dvwa的数据库 3.DVWA数据库配…

对接钉钉机器人发送钉钉通知

实现效果 话不多说 直接上代码 static void sendMsg(String msg) {try {String content "{\"msgtype\": \"text\",\"text\": {\"content\": \"" msg "\"}}";HttpUtil.simplePost(content, getDingU…

第3章 接口和API设计

第15条&#xff1a;用前缀避免命名空间冲突 OC没有其他语言那种内置的命名空间机制。因此&#xff0c;我们在起名时要设法避免潜在的命名冲突&#xff0c;否则很容易就重名了。若是发生重名冲突&#xff0c;那么应用程序相应的链接过程就会出错。例如&#xff1a; 错误原因在…

【并发编程】Java内存模型

&#x1f4dd;个人主页&#xff1a;五敷有你 &#x1f525;系列专栏&#xff1a;并发编程 ⛺️稳重求进&#xff0c;晒太阳 这一章进一步深入学习共享变量在多线程间的【可见性】问题&#xff0c;与多条指令执行时的【有序性】问题 Java内存模型 JMM即Java Memory Mod…

STM32实现软件IIC协议操作OLED显示屏(1)

时间记录&#xff1a;2024/1/25 一、IIC协议介绍 &#xff08;1&#xff09;协议介绍 IIC&#xff08;又称I2C&#xff0c;Inter-Integrated Circuit&#xff09;&#xff0c;即集成电路总线&#xff0c;是一种两线式串行总线&#xff0c;由PHILIPS公司开发&#xff0c;用…

MSG3D论文解读

论文在stgcn与sta-lstm基础上做的。下面讲一下里面的方法&#xff1a; 1.准备工作 符号。这里是对符号进行解释。 一个人体骨骼图被记为G(v,E) 图卷积&#xff1a; 图卷积定义 考虑一种常用于处理图像的标准卷积神经网络 (CNN)。输入是像素网格。每个像素都有一个数据值向…

喜报|「云原生数据库PolarDB」、「阿里云瑶池一站式数据管理平台」揽获“2023技术卓越奖”

日前&#xff0c;国内知名IT垂直媒体&技术社区IT168公布2023年“技术卓越奖”评选结果&#xff0c;经由行业CIO/CTO大咖、技术专家及IT媒体三方的联合严格评审&#xff0c;阿里云瑶池数据库揽获两项大奖&#xff1a;云原生数据库PolarDB荣获“2023年度技术卓越奖”&#xf…

GraphQL的力量:简化复杂数据查询

1. GraphQL GraphQL 是一种由 Facebook 开发并于 2015 年公开发布的数据查询和操作语言&#xff0c;也是运行在服务端的运行时&#xff08;runtime&#xff09;用于处理 API 查询的一种规范。不同于传统的 REST API&#xff0c;GraphQL 允许客户端明确指定它们需要哪些数据&am…

.net访问oracle数据库性能问题

问题&#xff1a; 生产环境相同的inser语句在别的非.NET程序相应明显快于.NET程序&#xff0c;执行时间相差比较大&#xff0c;影响正常业务运行&#xff0c;测试环境反而正常。 问题详细诊断过程 问题初步判断诊断过程&#xff1a; 查询插入慢的sql_id 检查对应的执行计划…