记一个带批注、表头样式的导入导出excel方法(基于easyexcel)
技术栈:easyexcel-2.2.10,poi-4.1.2,lombok,hutool-5.8.19;公司自用导入导出方法,可能不是那么的优雅,但胜在稳定实用。
/*** @Author 955* @Date 2023-10-10 11:52* @Description 错误批注信息对象*/
@Data
public class ErrorTypeNewVo implements Serializable {public ErrorTypeNewVo(String name, String message) {this.name = name;this.errors = message;}public ErrorTypeNewVo(String message, String name, int rownum, int cellnum) {this.name = name;this.errors = message;this.lineNum = rownum;this.cellnum = cellnum;}private String name;private String errors;private int lineNum;private int cellnum;}
一些要用到的工具类或方法
/*** 取得cell内的值** @param cell* @return*/public static String getStrByCell(Cell cell) {if (cell == null)return null;String temp = null;switch (cell.getCellType()) {case BLANK:case STRING:temp = cell.getStringCellValue();break;case FORMULA:try {temp = cell.getStringCellValue();} catch (IllegalStateException e) {temp = cell.getNumericCellValue() + "";}break;case NUMERIC:boolean remar = false;try {remar = DateUtil.isCellDateFormatted(cell);} catch (Exception e) {// TODO: handle exception}if (remar) {double d = cell.getNumericCellValue();Date date = DateUtil.getJavaDate(d);SimpleDateFormat a = new SimpleDateFormat("yyyy-MM-dd");temp = a.format(date);} else {temp = String.valueOf(cell.getNumericCellValue());}break;default:temp = cell.getStringCellValue();break;}if (temp.trim().equals(""))temp = null;elsetemp = temp.trim();return temp;}/*** 设置单元格样式** @param workbook* @param cell* @param col* @param fg*/public void setStyle(XSSFWorkbook workbook, Cell cell, String col, XSSFColor fg) {XSSFCellStyle style = workbook.createCellStyle();style.setFillForegroundColor(fg);// style.setFillPattern(CellStyle.SOLID_FOREGROUND);cell.setCellStyle(style);cell.setCellValue(col);}/*** 表头样式** @return*/public static WriteCellStyle getHeadWriteCellStyle() {WriteCellStyle headWriteCellStyle = new WriteCellStyle();headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);headWriteCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index);headWriteCellStyle.setBottomBorderColor(IndexedColors.BLACK.index);headWriteCellStyle.setLeftBorderColor(IndexedColors.BLACK.index);headWriteCellStyle.setRightBorderColor(IndexedColors.BLACK.index);headWriteCellStyle.setTopBorderColor(IndexedColors.BLACK.index);return headWriteCellStyle;}/*** 内容样式** @return*/public static WriteCellStyle getContentWriteCellStyle() {WriteCellStyle contentWriteCellStyle = new WriteCellStyle();contentWriteCellStyle.setWrapped(true);
// contentWriteCellStyle.setFillForegroundColor(IndexedColors.LEMON_CHIFFON.index);
// contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
// contentWriteCellStyle.setWriteFont();contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);return contentWriteCellStyle;}/*** 设置表头数据** @return*/private List<List<String>> head(List<String> titleName) {List<List<String>> list = new ArrayList<List<String>>();if (CollUtil.isNotEmpty(titleName)) {for (String s : titleName) {List<String> head = new ArrayList<String>();head.add(s);list.add(head);}}return list;}/*** @content 得到不同的时间类型* @author liuxd* @time 2011/07/24 22:00*/public static String getNow(int type) {SimpleDateFormat sdf = null;switch (type) {case 0:sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");break;case 1:sdf = new SimpleDateFormat("yyyyMMdd");break;case 2:sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");break;case 3:sdf = new SimpleDateFormat("yyyyMM");break;case 4:sdf = new SimpleDateFormat("yyyy年MM月dd日");break;case 5:sdf = new SimpleDateFormat("yyyy-MM-dd");break;case 6:sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); //取到毫秒break;case 7:sdf = new SimpleDateFormat("yyyyMMddHHmmss"); //取到秒break;default:sdf = new SimpleDateFormat("yyyy-M-D");break;}return sdf.format(new Date());}
导出方法体
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.excel.write.style.column.AbstractHeadColumnWidthStyleStrategy;
import lombok.AllArgsConstructor;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
import org.springframework.stereotype.Service;import java.io.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;private static int index = 500000;/*** * @param titleName sheet名称* @param tittleNames 标题集合* @param vos 内容详情集合* @param errorListVo 错误批注集合* @return*/public String newCreateExcelTemple_Object(String titleName, List<String> tittleNames, List<List<Object>> vos, List<ErrorTypeNewVo> errorListVo) {String fileName = OrgTools.getNow(6) + ".xlsx";//本地文件名随意取String locaPath = path + fileName;OutputStream out = null;try {out = new FileOutputStream(locaPath);} catch (FileNotFoundException e) {e.printStackTrace();}try {// 设置数据集合List<List<String>> dataList = new ArrayList<List<String>>();if (CollUtil.isNotEmpty(vos)) {for (List<Object> objects : vos) {List<String> strs = new ArrayList<>();for (Object obj : objects) {String str = null;if (obj != null) {if (obj instanceof Date) {SimpleDateFormat ff = new SimpleDateFormat("yyyy-MM-dd");str = ff.format(obj);} else {str = obj.toString();}}strs.add(str);}dataList.add(strs);}ExcelWriterBuilder writerBuilder = EasyExcel.write();writerBuilder.file(out);writerBuilder.excelType(ExcelTypeEnum.XLSX);writerBuilder.head(head(tittleNames));ExcelWriter excelWriter = writerBuilder.build();// 写第一个sheet, sheet1 数据全是List<String> 无模型映射关系long total = dataList.size();long count = total / 500000;if (total % 500000 > 0) {count++;}WriteCellStyle headWriteCellStyle = getHeadWriteCellStyle();WriteCellStyle contentWriteCellStyle = getContentWriteCellStyle();//这个策略是 头是头的样式 内容是内容的样式HorizontalCellStyleStrategy horizontalCellStyleStrategy =new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);for (int i = 0; i < count; i++) {List<List<String>> temp = new ArrayList<List<String>>();if (i == count - 1) {temp = dataList.subList(i * index, dataList.size());} else {temp = dataList.subList(i * index, (i + 1) * index);}WriteSheet sheet1 = EasyExcel.writerSheet(i, titleName + i).registerWriteHandler(horizontalCellStyleStrategy).registerWriteHandler(new AbstractHeadColumnWidthStyleStrategy() {@Overrideprotected Integer columnWidth(Head head, Integer columnIndex) {if (head == null) {return 17;}// 简单根据列头名称长度进行调整列的宽度// 当遍历完所有指定的head列头后// 第一行数据的第一列也会进入到这个逻辑, 此时head 为 nullreturn head.getHeadNameList().get(0).length() * 10;}}).build();excelWriter.write(temp, sheet1);}excelWriter.finish();}} catch (Exception e) {e.printStackTrace();} finally {try {if (out != null) {out.close();}} catch (IOException e) {e.printStackTrace();}}InputStream inputStream = null;try {inputStream = new FileInputStream(locaPath);XSSFWorkbook wb = new XSSFWorkbook(inputStream);XSSFSheet sheet = wb.getSheetAt(0);for (ErrorTypeNewVo errorTypevo : errorListVo) {Row row = sheet.getRow(errorTypevo.getLineNum());Cell cell = row.getCell(errorTypevo.getCellnum());if (cell == null) {cell = row.getCell(errorTypevo.getCellnum() - 1);}String name = errorTypevo.getName();String messageAll = errorTypevo.getErrors();String message = "";if (StrUtil.isNotEmpty(name)) {message += "错误类型:" + name;}if (StrUtil.isNotEmpty(messageAll)) {message += ",详细错误:" + messageAll;}String t1 = "";try {t1 = getStrByCell(cell);} catch (Exception e) {e.printStackTrace();}XSSFColor color = new XSSFColor(java.awt.Color.red);if (t1 != null) {setStyle(wb, cell, t1, color);} else {t1 = "";if (StrUtil.isNotEmpty(name)) {t1 += "错误类型:" + name;}if (StrUtil.isNotEmpty(messageAll)) {t1 += ",详细错误:" + messageAll;}setStyle(wb, cell, t1, color);}if (cell != null) {//设置批注:能解决Multiple cell comments in one cell are not allowed, cell: xx问题Comment mainComment = cell.getCellComment();if (ObjectUtil.isEmpty(mainComment)) {mainComment = sheet.createDrawingPatriarch().createCellComment(new XSSFClientAnchor(0, 0, 0, 0, cell.getColumnIndex(), cell.getRowIndex(), cell.getColumnIndex() + 2, cell.getRowIndex() + 3));mainComment.setString(new XSSFRichTextString(message));cell.setCellComment(mainComment);sheet.autoSizeColumn(cell.getColumnIndex());}}}// 临时缓冲区ByteArrayOutputStream out2 = new ByteArrayOutputStream();// 创建临时文件wb.write(out2);byte[] bookByteAry = out2.toByteArray();inputStream = new ByteArrayInputStream(bookByteAry);try {//只需替换这里的系统文件导出方法即可fileTemplate.putObject("桶名", fileName, inputStream);} catch (Exception e) {e.printStackTrace();}} catch (FileNotFoundException e1) {e1.printStackTrace();} catch (IOException e) {e.printStackTrace();} finally {if (inputStream != null) {try {inputStream.close();} catch (IOException e) {e.printStackTrace();} finally {File file1 = new File(locaPath);if (file1.exists() && file1.isFile()) {file1.delete();}}}}return fileName;}
导入vo对象示例
@Data
@ColumnWidth(value = 30)
public class ExamExcelVo {@ExcelProperty(value = "考试题目", index = 0)private String questionStem;@ExcelProperty(value = "答题类型", converter = EasyExcelTopicTypeConverter.class, index = 1)private String questionType;@ExcelProperty(value = "正确答案", index = 2)private String answer;@ExcelProperty(value = "考题标签", index = 3)private String major;@ExcelProperty(value = "题要求", converter = EasyExcelDemandConverter.class, index = 4)private String demand;@ExcelProperty(value = "选项A", index = 5)private String optionA;@ExcelProperty(value = "选项B", index = 6)private String optionB;@ExcelProperty(value = "选项C", index = 7)private String optionC;@ExcelProperty(value = "选项D", index = 8)private String optionD;@ExcelProperty(value = "选项E", index = 9)private String optionE;/*** 判断正确选项,反射得到字段值(非必要)** @return*/public List<String> concatenateFields() {List<String> values = new ArrayList<>();try {if (StrUtil.isNotEmpty(answer)) {answer = answer.replaceAll(" ", "");// 使用 HashSet 来存储不重复的字母Set<Character> uniqueLetters = new HashSet<>();// 使用正则表达式匹配 A 到 Z 和 a 到 z 的字母Pattern pattern = Pattern.compile("[a-zA-Z]");Matcher matcher = pattern.matcher(answer);while (matcher.find()) {char letter = matcher.group().charAt(0);// 使用大写字母存储,以忽略大小写uniqueLetters.add(Character.toUpperCase(letter));}List<String> r = new ArrayList<>();for (char letter : uniqueLetters) {r.add(letter + "");}for (String fieldName : r) {Field field = this.getClass().getDeclaredField("option" + fieldName);String value = (String) field.get(this);values.add(value);}}} catch (Exception e) {}return values;}
}
字段处理示例
/*** @Author 955* @Date 2023-09-21 18:28* @Description 字段处理*/
public class EasyExcelTopicTypeConverter implements Converter<String> {@Overridepublic Class<String> supportJavaTypeKey() {return String.class;}@Overridepublic CellDataTypeEnum supportExcelTypeKey() {return CellDataTypeEnum.STRING;}@Overridepublic String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {if (StrUtil.isNotEmpty(cellData.getStringValue())) {//处理逻辑。。。//最终返回的值return xxx;}return null;}@Overridepublic CellData convertToExcelData(String value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {if (StrUtil.isNotEmpty(value)) {String name = CourseBaseEnum.ExamType.getNameById(value);return new CellData(name);}return new CellData("");}
}
工具方法
/*** 剔除全部字段为null数据对象** @param excelVo*/private void eliminateNullList(List<ExamExcelVo> excelVo) {if (excelVo != null) {Iterator<ExamExcelVo> iterator = excelVo.iterator();while (iterator.hasNext()) {ExamExcelVo next = iterator.next();if (isAllFieldNull(next)) {iterator.remove();}}}}/*** 获取表头集合* @param t* @param objmap* @return*/public Map<String, Integer> getFieldAnnotations(Class t, Map<String, Integer> objmap) {try {Map<String, Integer> heads = new LinkedHashMap<>();Field[] fields = t.getDeclaredFields();for (Field field : fields) {ExcelProperty excelpro = (ExcelProperty) field.getAnnotation(ExcelProperty.class);heads.put(excelpro.value()[0], excelpro.index());
// heads.add(excelpro.value()[0]);objmap.put(field.getName(), excelpro.index());}return heads;} catch (Exception e) {e.printStackTrace();}return null;}
模版导入返回带批注的错误信息方法
public R<?> importExams(List<ExamExcelVo> excelVo) {List<List<Object>> errorList = new ArrayList<List<Object>>();eliminateNullList(excelVo);try {List<ErrorTypeNewVo> errorListVo = new ArrayList<>();Map<String, Integer> objmap = new LinkedHashMap<>();Map<String, Integer> heads = getFieldAnnotations(ExamExcelVo.class, objmap);for (int i = 0; i < excelVo.size(); i++) {List<ErrorTypeNewVo> errorTypeVos = new ArrayList<ErrorTypeNewVo>();ExamExcelVo vo = excelVo.get(i);String questionStem = vo.getQuestionStem();ExaminationQuestion question = new ExaminationQuestion();if (StrUtil.isEmpty(questionStem)) {errorTypeVos.add(new ErrorTypeNewVo("题目内容为空", "请重新填写", errorList.size() + 1, heads.get("考试题目")));} else {question.setQuestionStem(questionStem);}//.......等等等等判断if (CollUtil.isEmpty(errorTypeVos)) {//没有错误信息操作.......} else {//有错误信息操作List<Object> o = new ArrayList<>();Map<String, Object> map = BeanUtil.beanToMap(vo);for (Map.Entry<String, Integer> entry : objmap.entrySet()) {if (map.get(entry.getKey()) != null) {o.add(map.get(entry.getKey()));} else {o.add("");}}errorList.add(o);errorListVo.addAll(errorTypeVos);}}if (errorListVo.size() > 0) {//生成错误文件String XSSFSheetName = "导入错误信息" + System.currentTimeMillis();List<String> collect = heads.keySet().stream().collect(Collectors.toList());//调用上方导出方法String BUCKET_NAME = newCreateExcelTemple_Object(XSSFSheetName, collect, errorList, errorListVo);return 导入有错误信息;}} catch (Exception e) {e.printStackTrace();}return 导入成功信息;}
导入接口示例:
@ApiOperation("批量导入试题")@PostMapping(value = "/importExams")public 返回参数 importExams(@RequestExcel List<ExamExcelVo> excelVo) {return importExams(excelVo);}
相关文章:
记一个带批注、表头样式的导入导出excel方法(基于easyexcel)
技术栈:easyexcel-2.2.10,poi-4.1.2,lombok,hutool-5.8.19;公司自用导入导出方法,可能不是那么的优雅,但胜在稳定实用。 /*** Author 955* Date 2023-10-10 11:52* Description 错误批注信息对…...

二叉搜索树--新增节点-力扣 701 题
例题细节二叉搜索树的基础操作-CSDN博客也讲过了(put),下面给出递归实现 public TreeNode insertIntoBST(TreeNode node, int val) {//找到空位了if(node null) {return new TreeNode(val);}if(val < node.val) {//一直找到有null的位置…...

C++ - 智能指针 - auto_ptr - unique_ptr - std::shared_ptr - weak_ptr
前言 C当中的内存管理机制需要我们自己来进行控制,比如 在堆上 new 了一块空间,那么当这块空间不需要再使用的时候。我们需要手动 delete 掉这块空间,我们不可能每一次都会记得,而且在很大的项目程序当中,造成内存泄漏…...

【快速入门】JVM之类加载机制与Native
感慨: 如何定义一个合格的Java程序员,Java程序员要了解掌握哪些知识点,网上的面试题太多了,后端需要了解掌握的知识点太多太多了,Java基础、数据结构、异常、多线程、Spring、Spring boot、事务、算法、数据库…...

R实现数据分布特征的视觉化——多笔数据之间的比较
大家好,我是带我去滑雪! 如果要对两笔数据或者多笔数据的分布情况进行比较,Q-Q图、柱状图、星形图都是非常好的选择,下面开始实战。 (1)绘制Q-Q图 首先导入数据bankwage.csv文件,该数据集…...

TCPUDP
TCP 1.什么是TCP TCP是处于运输层的通信协议,该协议能够实现数据的可靠性传输。 2.TCP报文格式 源端口和目的端口:各占两个字节,发送进程的端口和接收进程的端口号。 序号:占4个字节,序号如果增加到溢出,则下一个序…...

设计模式 - 备忘录模式
目录 一. 前言 二. 实现 三. 优缺点 一. 前言 备忘录模式又称快照模式,是一种行为型设计模式。它可以在不破坏封装性的前提下捕获一个对象的内部状态,并在对象之外保存这个状态,以便在需要的时候恢复到原先保存的状态。在不违反封装的情况…...

OpenCV4(C++)—— 几何图形的绘制
文章目录 一、基本图形1、线2、线圆3、线椭圆4、矩形 二、多边形 一、基本图形 1、线 绘制线,要给出两个点坐标 void cv::line(InputOutputArray img, Point pt1, Point pt2, const Scalar& color, int thickness 1, int lineType LINE_8, int shift 0);…...

智能优化算法常用指标一键导出为EXCEL,CEC2017函数集最优值,平均值,标准差,最差值,中位数,秩和检验,箱线图...
声明:对于作者的原创代码,禁止转售倒卖,违者必究! 之前出了一篇关于CEC2005函数集的智能算法指标一键统计,然而后台有很多小伙伴在询问其他函数集该怎么调用。今天采用CEC2017函数集为例,进行展示。 为了突…...
python文件打包方式汇总
在Python中,你可以使用多种方法来打包你的项目,以下是最常见的两种方式: 使用PyInstaller: PyInstaller是一个非常实用的工具,可以将Python程序打包成独立的可执行文件。这样,你就可以在没有Python环境的…...

基于ChatGPT+词向量/词嵌入实现相似商品推荐系统
最近一个项目有个业务场景是相似商品推荐,给一个商品描述(比如 WIENER A/B 7IN 5/LB FZN ),系统给出商品库中最相似的TOP 5种商品,这种单纯的推荐系统用词向量就可以实现,不过,这个项目特点是商品库巨大,有…...

虾皮商品链接获取虾皮商品详情数据(用 Python实现虾皮商品信息抓取)
在网页抓取方面,可以使用 Python、Java 等编程语言编写程序,通过模拟 HTTP 请求,获取虾皮网站上的商品页面。在数据提取方面,可以使用正则表达式、XPath 等方式从 HTML 代码中提取出有用的信息。值得注意的是,虾皮网站…...
【数据库系统概论】数据查询之单表查询。详细解释WHERE、OEDER BY、GROUP BY 和 HAVING
前言 ❓单表查询选择表中的若干列查询经过计算的值选择表中的若干元组(行)消除取值重复的行查询满足条件的元组(WHERE) 对查询结果排序(ORDER BY)聚集函数对查询结果分组(GROUP BY) …...

2023年医药商业行业发展研究报告
第一章 行业概况 1.1 定义 医药商业行业,作为医药领域的重要组成部分,扮演着至关重要的角色。这一行业专注于医药商品的经营与流通,确保药品能够有效、安全地到达消费者手中。随着医药科技的进步和市场需求的增长,医药商业行业在…...
Android 消息机制
Android 消息机制 Android 的消息机制也是Handler机制,主要作用是用来在不同线程之间通信,通常使用在子线程执行完成一些儿耗时操作,需要回到主线程更新UI时,通过Handler将有关UI操作切换到主线程。由于Android中主线程不可进行耗…...
QT计时器QTime的使用举例
Qt 中的计时器(QTimer)是一种用于执行定时操作的机制。您可以使用 QTimer 来执行周期性任务、在一段时间后执行操作或创建间隔定时器。以下是使用 QTimer 的基本步骤以及一个简单的示例: **包含头文件:**首先,确保您的…...
js中await用法
在JavaScript中,await用于暂停异步函数执行,等待Promise对象的解决。当Promise对象解决时,await将返回被解决的值,否则它将抛出一个被拒绝的Promise错误。 下面是一些使用await的例子: 使用await等待一个Promise对象…...

Qt多工程同名字段自动翻译工具
开发背景 项目里不同工程经常会引用同一批公共类,这些类里如果有字段需要翻译,需要在不同的项目里都翻译一遍,比较麻烦冗余。 特此开发了这个小翻译工具,能读取程序目录下的所有ts文件,以类名归类,不同项目…...

vue3+elementui实现表格样式可配置
后端接口传回的数据格式如下图 需要依靠后端传回的数据控制表格样式 实现代码 <!-- 可视化配置-表格 --> <template><div class"tabulation_main" ref"myDiv"><!-- 尝试过在mounted中使用this.$refs.myDiv.offsetHeight,获取父元素…...
x11截屏源码(ubuntu18.04)
使用x11库实现截屏并保存为png图片 【shot.c】 // filename: shot.c #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xatom.h> #include <X11/cursorfont.h> #include <png.h> #include <stdio.h> #include <stdlib.h>…...

STM32标准库-DMA直接存储器存取
文章目录 一、DMA1.1简介1.2存储器映像1.3DMA框图1.4DMA基本结构1.5DMA请求1.6数据宽度与对齐1.7数据转运DMA1.8ADC扫描模式DMA 二、数据转运DMA2.1接线图2.2代码2.3相关API 一、DMA 1.1简介 DMA(Direct Memory Access)直接存储器存取 DMA可以提供外设…...
生成 Git SSH 证书
🔑 1. 生成 SSH 密钥对 在终端(Windows 使用 Git Bash,Mac/Linux 使用 Terminal)执行命令: ssh-keygen -t rsa -b 4096 -C "your_emailexample.com" 参数说明: -t rsa&#x…...
论文解读:交大港大上海AI Lab开源论文 | 宇树机器人多姿态起立控制强化学习框架(一)
宇树机器人多姿态起立控制强化学习框架论文解析 论文解读:交大&港大&上海AI Lab开源论文 | 宇树机器人多姿态起立控制强化学习框架(一) 论文解读:交大&港大&上海AI Lab开源论文 | 宇树机器人多姿态起立控制强化…...
解决本地部署 SmolVLM2 大语言模型运行 flash-attn 报错
出现的问题 安装 flash-attn 会一直卡在 build 那一步或者运行报错 解决办法 是因为你安装的 flash-attn 版本没有对应上,所以报错,到 https://github.com/Dao-AILab/flash-attention/releases 下载对应版本,cu、torch、cp 的版本一定要对…...

如何理解 IP 数据报中的 TTL?
目录 前言理解 前言 面试灵魂一问:说说对 IP 数据报中 TTL 的理解?我们都知道,IP 数据报由首部和数据两部分组成,首部又分为两部分:固定部分和可变部分,共占 20 字节,而即将讨论的 TTL 就位于首…...

九天毕昇深度学习平台 | 如何安装库?
pip install 库名 -i https://pypi.tuna.tsinghua.edu.cn/simple --user 举个例子: 报错 ModuleNotFoundError: No module named torch 那么我需要安装 torch pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple --user pip install 库名&#x…...

【网络安全】开源系统getshell漏洞挖掘
审计过程: 在入口文件admin/index.php中: 用户可以通过m,c,a等参数控制加载的文件和方法,在app/system/entrance.php中存在重点代码: 当M_TYPE system并且M_MODULE include时,会设置常量PATH_OWN_FILE为PATH_APP.M_T…...

【从零开始学习JVM | 第四篇】类加载器和双亲委派机制(高频面试题)
前言: 双亲委派机制对于面试这块来说非常重要,在实际开发中也是经常遇见需要打破双亲委派的需求,今天我们一起来探索一下什么是双亲委派机制,在此之前我们先介绍一下类的加载器。 目录 编辑 前言: 类加载器 1. …...

破解路内监管盲区:免布线低位视频桩重塑停车管理新标准
城市路内停车管理常因行道树遮挡、高位设备盲区等问题,导致车牌识别率低、逃费率高,传统模式在复杂路段束手无策。免布线低位视频桩凭借超低视角部署与智能算法,正成为破局关键。该设备安装于车位侧方0.5-0.7米高度,直接规避树枝遮…...

认识CMake并使用CMake构建自己的第一个项目
1.CMake的作用和优势 跨平台支持:CMake支持多种操作系统和编译器,使用同一份构建配置可以在不同的环境中使用 简化配置:通过CMakeLists.txt文件,用户可以定义项目结构、依赖项、编译选项等,无需手动编写复杂的构建脚本…...