当前位置: 首页 > news >正文

java-poi实现excel自定义注解生成数据并导出

        因为项目很多地方需要使用导出数据excel的功能,所以开发了一个简易的统一生成导出方法。

依赖

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

定义注解

标题栏注解 

import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.IndexedColors;import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface ExcelTitle {/*** 标题名称* @return 默认空*/String titleName() ;/*** 标题背景* @return 默认空*/IndexedColors titleBack() default IndexedColors.WHITE;/*** 标题文字大小* @return 默认空*/short titleSize() default 14;/*** 标题文字颜色* @return 黑色*/HSSFColor.HSSFColorPredefined titleColor() default HSSFColor.HSSFColorPredefined.BLACK;/*** 边框格式* @return 细*/BorderStyle borderStyle() default BorderStyle.THIN;/*** 边框颜色* @return 默认*/IndexedColors borderColor() default IndexedColors.AUTOMATIC;/*** 标题文字加粗* @return 黑色*/boolean boldFont() default true;/*** 是否忽略* @return 黑色*/boolean ignore() default false;/*** 排序* @return 0*/int order() default 0;
}

数据栏注解

import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.VerticalAlignment;import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;/*** @description: excel导出结果配置*/
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface ExcelProperty {/*** 背景* @return 默认空*/IndexedColors textBack() default IndexedColors.WHITE;/*** 内容类型,查看* @link org.apache.poi.ss.usermodel.BuiltinFormats* @return 默认TEXT*/String textType() default "TEXT";/*** 文字大小* @return 默认18*/short textSize() default 12;/*** 数据属于key:value时,可以自定义转换,配置格式为:key1=value;key2=value2;.....* @return 默认空*/String textKv() default "";/*** 文字颜色* @return 黑色*/HSSFColor.HSSFColorPredefined textColor() default HSSFColor.HSSFColorPredefined.BLACK;/*** 水平位置* @return 水平居中*/HorizontalAlignment horizontal() default HorizontalAlignment.CENTER;/*** 垂直位置* @return 垂直居中*/VerticalAlignment vertical() default VerticalAlignment.CENTER;/*** 文字加粗* @return 不加粗*/boolean boldFont() default false;
}

代码

 标题栏格式生成

        解析对象属性的@ExcelTitle注解的信息,并设置相关选项。

private CellStyle initTitleCellStyle(SXSSFWorkbook wb, Field titleField) {// 单元格样式XSSFCellStyle cellStyle = (XSSFCellStyle) wb.createCellStyle();//水平居中cellStyle.setAlignment(HorizontalAlignment.CENTER);//垂直居中cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);ExcelTitle excelTitle = titleField.getAnnotation(ExcelTitle.class);//背景颜色if(excelTitle != null && excelTitle.titleBack() != null){cellStyle.setFillForegroundColor(excelTitle.titleBack().getIndex());}  else {cellStyle.setFillForegroundColor(IndexedColors.WHITE1.getIndex());}//文字的设置字体颜色Font font = wb.createFont();if(excelTitle != null && excelTitle.titleColor() != null){font.setColor(excelTitle.titleColor().getIndex());}  else {font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());}font.setBold(excelTitle != null && excelTitle.boldFont());font.setFontHeightInPoints(excelTitle != null && excelTitle.titleSize() != 0 ? excelTitle.titleSize(): 12);cellStyle.setFont(font);//设置为文本格式cellStyle.setDataFormat(BuiltinFormats.getBuiltinFormat("TEXT"));cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);//边框if(excelTitle != null && excelTitle.borderStyle() != null){cellStyle.setBorderTop(excelTitle.borderStyle());cellStyle.setBorderBottom(excelTitle.borderStyle());cellStyle.setBorderLeft(excelTitle.borderStyle());cellStyle.setBorderRight(excelTitle.borderStyle());} else {cellStyle.setBorderTop(BorderStyle.THIN);cellStyle.setBorderBottom(BorderStyle.THIN);cellStyle.setBorderLeft(BorderStyle.THIN);cellStyle.setBorderRight(BorderStyle.THIN);}//边框if(excelTitle != null && excelTitle.borderColor() != null){cellStyle.setTopBorderColor(excelTitle.borderColor().getIndex());cellStyle.setBottomBorderColor(excelTitle.borderColor().getIndex());cellStyle.setLeftBorderColor(excelTitle.borderColor().getIndex());cellStyle.setRightBorderColor(excelTitle.borderColor().getIndex());} else {cellStyle.setTopBorderColor(IndexedColors.RED.getIndex());cellStyle.setBottomBorderColor(IndexedColors.RED.getIndex());cellStyle.setLeftBorderColor(IndexedColors.RED.getIndex());cellStyle.setRightBorderColor(IndexedColors.RED.getIndex());}return cellStyle;}

数据栏格式生成

  解析对象属性的@ExcelProperty注解的信息,并设置相关选项。

private CellStyle initCellStyle(SXSSFWorkbook wb, Field titleField) {// 单元格样式(垂直居中)XSSFCellStyle cellStyle = (XSSFCellStyle) wb.createCellStyle();ExcelProperty excelProperty = titleField.getAnnotation(ExcelProperty.class);//水平居中if(excelProperty != null && excelProperty.horizontal() != null) {cellStyle.setAlignment(excelProperty.horizontal());}//垂直居中if(excelProperty != null && excelProperty.vertical() != null) {cellStyle.setVerticalAlignment(excelProperty.vertical());}//背景颜色if(excelProperty != null && excelProperty.textBack() != null){cellStyle.setFillForegroundColor(excelProperty.textBack().getIndex());}//文字的设置字体颜色Font font = wb.createFont();if(excelProperty != null && excelProperty.textColor() != null){font.setColor(excelProperty.textColor().getIndex());}font.setBold(excelProperty != null && excelProperty.boldFont());font.setFontHeightInPoints(excelProperty != null && excelProperty.textSize() != 0 ? excelProperty.textSize(): 12);cellStyle.setFont(font);cellStyle.setBorderTop(BorderStyle.THIN);cellStyle.setBorderBottom(BorderStyle.THIN);cellStyle.setBorderLeft(BorderStyle.THIN);cellStyle.setBorderRight(BorderStyle.THIN);//设置为文本格式cellStyle.setDataFormat(BuiltinFormats.getBuiltinFormat(excelProperty != null && excelProperty.textType() != null ? excelProperty.textType() : "TEXT"));cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);return cellStyle;}

同时提供一个默认的配置:

private CellStyle initDefaultCellStyle(SXSSFWorkbook wb) {// 单元格样式(垂直居中)XSSFCellStyle cellStyle = (XSSFCellStyle) wb.createCellStyle();//水平居中cellStyle.setAlignment(HorizontalAlignment.CENTER);//垂直居中cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//设置为文本格式cellStyle.setDataFormat(BuiltinFormats.getBuiltinFormat("TEXT"));//文字的设置Font font = wb.createFont();font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());   //设置字体颜色return cellStyle;}

解析数据,生成sheet

private SXSSFWorkbook creatBook(List<ExcelSheetVo> list) {//创建工作簿SXSSFWorkbook wb = new SXSSFWorkbook();for (ExcelSheetVo excelSheetVo : list) {createSXSSFSheet(excelSheetVo, wb);}return wb;}private SXSSFSheet createSXSSFSheet(ExcelSheetVo excelSheetVo, SXSSFWorkbook wb) {//创建工作簿SXSSFSheet sxssfSheet = wb.createSheet(excelSheetVo.getSheetName());//设置默认的行宽sxssfSheet.setDefaultColumnWidth(20);//设置morning的行高(不能设置太小,可以不设置)sxssfSheet.setDefaultRowHeight((short) 300);//设置morning的单元格格式//CellStyle style = initCellStyle(wb);//标题单元格格式//CellStyle titleStyle = initTitleCellStyle(wb, excelSheetVo.getDataClass());//初始化标题栏initTitle(wb, sxssfSheet, excelSheetVo.getDataClass());initSheetData(wb, sxssfSheet, excelSheetVo, 1);return sxssfSheet;}private void initSheetData(SXSSFWorkbook wb, SXSSFSheet sxssfSheet, ExcelSheetVo excelSheetVo, int dataStartLine) {if (CollectionUtils.isEmpty(excelSheetVo.getSheetData())) {return;}try {for (Object dataObject : excelSheetVo.getSheetData()) {SXSSFRow row = sxssfSheet.createRow(dataStartLine);Field[] fields = dataObject.getClass().getDeclaredFields();List<Field> fieldList = Arrays.stream(fields).filter(item -> item.getAnnotation(ExcelTitle.class) != null && !item.getAnnotation(ExcelTitle.class).ignore()).sorted(Comparator.comparingInt(item -> {ExcelTitle excelTitle = item.getAnnotation(ExcelTitle.class);return excelTitle.order();})).collect(Collectors.toList());for (int i = 0; i < fieldList.size(); i++) {//根据title的值对应的值SXSSFCell cell = row.createCell(i);Field field = fieldList.get(i);cell.setCellStyle(initCellStyle(wb, field));field.setAccessible(true);cell.setCellValue(dealValue(field, dataObject));}dataStartLine++;}} catch (Exception e){LOGGER.error("生成数据异常", e);}}

key:value数据解析

private String dealValue(Field field, Object dataObject) throws IllegalAccessException {ExcelProperty excelProperty = field.getAnnotation(ExcelProperty.class);Object value = field.get(dataObject);if(value == null){return null;}if(excelProperty != null && StringUtils.isNotEmpty(excelProperty.textKv())){String[] kvs = excelProperty.textKv().split(";");Map<String, String> map = new HashMap<>();for(String str: kvs){map.put(str.split("=")[0], str.split("=")[1]);}return map.get(value.toString());}return value.toString();}

导出设置:

/*** 导出excel数据** @param response 亲求返回* @param list     每个sheet页的数据,一个elist表示一个sheet页* @param fileName 导出的名称* @return 结果*/public boolean creatExcel(HttpServletResponse response, List<ExcelSheetVo> list, String fileName) {SXSSFWorkbook wb = creatBook(list);//导出数据try {//设置Http响应头告诉浏览器下载这个附件response.reset();response.setCharacterEncoding("utf-8");response.setContentType("application/vnd.ms-excel");//名称要从新进行 ISO8859-1 编码否则会文件名称会乱码response.setHeader("Content-Disposition", "attachment;Filename=" + encodeFileName(fileName) + ".xlsx");OutputStream outputStream = response.getOutputStream();ByteArrayOutputStream baos = new ByteArrayOutputStream();wb.write(baos);outputStream.write(baos.toByteArray());baos.flush();baos.close();outputStream.close();} catch (Exception ex) {LOGGER.error("导出excel失败", ex);}return true;}private String encodeFileName(String fileName) {try {//fileName = java.net.URLEncoder.encode(fileName, "UTF-8");fileName = URLDecoder.decode(fileName, "UTF-8");return new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);} catch (UnsupportedEncodingException e) {return "未命名";}}

测试

定义数据实体

数据标题和数据定义

@Data
public class TestExcelVo {@ExcelTitle(titleName = "名称", titleColor = HSSFColor.HSSFColorPredefined.BLUE, borderStyle = BorderStyle.HAIR, titleSize = 12, titleBack = IndexedColors.YELLOW)@ExcelProperty()private String name;@ExcelTitle(titleName = "年龄", titleColor = HSSFColor.HSSFColorPredefined.GREEN, borderStyle = BorderStyle.HAIR, titleBack = IndexedColors.RED)@ExcelProperty(textType = "0", textColor = HSSFColor.HSSFColorPredefined.RED)private Integer age;@ExcelTitle(titleName = "性别", titleColor = HSSFColor.HSSFColorPredefined.BLUE, titleSize = 12, titleBack = IndexedColors.GREEN)@ExcelProperty(textKv = "0=男;1=女", textBack = IndexedColors.BROWN)private Integer sex;@ExcelTitle(titleName = "描述", titleColor = HSSFColor.HSSFColorPredefined.BLUE, titleBack = IndexedColors.GREEN)@ExcelProperty(boldFont = true, textSize = 18)private String des;
}

sheet的数据定义 

@Data
public class ExcelSheetVo<T> {/*** 每一个sheet页得名称*/private String sheetName;/*** 每个sheet里面得数据* 其中Object中得注解必须时包含 @ExcelTitle 和 @ExcelProperties*/private List<T> sheetData;/*** 数据对象得类型*/private Class dataClass;
}

测试代码

@RestController
@RequestMapping(value = "exceExport")
public class ExcelExportController {@GetMapping("testExport")public void testExport(HttpServletResponse response){String fileName = "测试sheet";List<ExcelSheetVo> sheetVoList = new ArrayList<>();for(int i = 0; i < 3; i++){sheetVoList.add(createSheetData(i));}new ExcelCreateUtil().creatExcel(response, sheetVoList, fileName);}private ExcelSheetVo<TestExcelVo> createSheetData(int index){ExcelSheetVo<TestExcelVo> excelSheetVo = new ExcelSheetVo<>();excelSheetVo.setDataClass(TestExcelVo.class);excelSheetVo.setSheetName("sheet" + index);List<TestExcelVo> testExcelVos = createTestExcelVo(new Random().nextInt(30) + 10, "sheet" + index);excelSheetVo.setSheetData(testExcelVos);return excelSheetVo;}private List<TestExcelVo> createTestExcelVo(int size, String sheetName){List<TestExcelVo> testExcelVos = new ArrayList<>();for(int i = 0; i < size; i++){TestExcelVo testExcelVo = new TestExcelVo();testExcelVo.setName(sheetName + "-" + i);testExcelVo.setAge(i);testExcelVo.setSex(i % 2);testExcelVo.setDes("哈哈哈哈哈" + i);testExcelVos.add(testExcelVo);}return testExcelVos;}
}

结果:

相关文章:

java-poi实现excel自定义注解生成数据并导出

因为项目很多地方需要使用导出数据excel的功能&#xff0c;所以开发了一个简易的统一生成导出方法。 依赖 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>4.0.1</version…...

LeetCode707 设计链表

前言 题目&#xff1a; 707. 设计链表 文档&#xff1a; 代码随想录——设计链表 编程语言&#xff1a; C 解题状态&#xff1a; 代码功底不够&#xff0c;只能写个大概 思路 主要考察对链表结构的熟悉程度&#xff0c;对链表的增删改查&#xff0c;比较考验代码功底以及对链表…...

[Mysql-DDL数据操作语句]

目录 DDL语句操作数据库 库&#xff1a; 查看&#xff1a;show 创建&#xff1a;creat 删除&#xff1a;drop 使用(切换)&#xff1a;use 表&#xff1a; 查看&#xff1a;desc show 创建&#xff1a;create 表结构修改 rename as add drop modify change rename as …...

google 浏览器插件开发简单学习案例:TodoList;打包成crx离线包

参考&#xff1a; google插件支持&#xff1a; https://blog.csdn.net/weixin_42357472/article/details/140412993 这里是把前面做的TodoList做成google插件&#xff0c;具体网页可以参考下面链接 TodoList网页&#xff1a; https://blog.csdn.net/weixin_42357472/article/de…...

如何学习Doris:糙快猛的大数据之路(从入门到专家)

引言:大数据世界的新玩家 还记得我第一次听说"Doris"这个名字时的情景吗?那是在一个炎热的夏日午后,我正在办公室里为接下来的大数据项目发愁。作为一个刚刚跨行到大数据领域的新手,我感觉自己就像是被丢进了深海的小鱼—周围全是陌生的概念和技术。 就在这时,我的…...

梯度下降算法,gradient descent algorithm

定义&#xff1a;是一个优化算法&#xff0c;也成最速下降算法&#xff0c;主要的部的士通过迭代找到目标函数的最小值&#xff0c;或者收敛到最小值。 说人话就是求一个函数的极值点&#xff0c;极大值或者极小值 算法过程中有几个超参数&#xff1a; 学习率n&#xff0c;又称…...

Spring boot 2.0 升级到 3.3.1 的相关问题 (六)

文章目录 Spring boot 2.0 升级到 3.3.1 的相关问题 &#xff08;六&#xff09;spring-data-redis 和 Spring AOP 警告的问题问题描述问题调研结论解决方案方案1-将冲突的Bean 提升为InfrastructureBean方案2 其他相关资料 Spring boot 2.0 升级到 3.3.1 的相关问题 &#xff…...

C++模版基础知识与STL基本介绍

目录 一. 泛型编程 二. 函数模板 1. 概念 2. 函数模版格式 3. 函数模版的原理 4. 模版函数的实例化 (1). 隐式实例化 (2.) 显式实例化 5. 模版参数的匹配原则 三. 类模板 1. 类模板的定义格式 2. 类模板的实例化 四. STL的介绍 1. 什么是STL&#xff1f; 2. STL的版…...

Android 防止重复点击

1.第一种方式&#xff1a; // 两次点击按钮之间的点击间隔不能少于1000毫秒 private static final int MIN_CLICK_DELAY_TIME 700; private static long lastClickTime; /** * 是否是快速点击 * return */ public static boolean isFastClick() { …...

使用阿里云云主机通过nginx搭建文件服务器

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、准备基础环境二、安装配置nginx三、阿里云安全组配置安全组配置 ![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/4ee96f38312e4771938e40f463987…...

微信Android一面凉经(2024)

微信Android一面凉经(2024) 笔者作为一名双非二本毕业7年老Android, 最近面试了不少公司, 目前已告一段落, 整理一下各家的面试问题, 打算陆续发布出来, 供有缘人参考。今天给大家带来的是《微信Android一面凉经(2024)》。 面试职位: 微信-客户端开发工程师-基础功能(广州) And…...

VMware、Docker - 让虚拟机走主机代理,解决镜像封禁问题

文章目录 虚拟机全局代理配置找到 VMnet8 的 IPv4 地址代理相关配置虚拟机代理配置 Docker 代理配置修改镜像修改 Docker 代理配置 虚拟机全局代理配置 找到 VMnet8 的 IPv4 地址 a&#xff09;打开此电脑&#xff0c;输入 “控制面板”&#xff0c;然后回车. b&#xff09;之…...

版本管理|为什么不推荐使用Git Rebase

文章目录 什么是 Git Rebase&#xff1f;如何使用 Git Rebase&#xff1f;基本语法示例更多选项 注意事项何时使用何时避免其他注意事项 为什么需要谨慎使用 Git Rebase&#xff1f;面试中的常见问题问题 1: Git Rebase 和 Git Merge 有何不同&#xff1f;问题 2: 为什么有时应…...

Https post 请求时绕过证书验证方案

解决异常&#xff1a;Caused by: java.security.cert.CertificateException: No subject alternative names matching IP address xxx.xx.xx.xx found // Https POST 请求private cn.hutool.json.JSON PostGsData(String url, String appKey, String token, Map<String, Ob…...

C# 数组常用遍历方式

// 假设数组Point[] points new Point[2];// 第一种遍历 forfor (int i 0; i < points.Length; i){Point p points[i];Console.WriteLine($"X{p.X},y{p.Y}");}// 第二种遍历 foreachforeach (Point p in points){Console.WriteLine($"X{p.X},y{p.Y}"…...

【JavaScript】详解Day.js:轻量级日期处理库的全面指南

文章目录 一、Day.js简介1. 什么是Day.js&#xff1f;2. 安装Day.js 二、Day.js的基本用法1. 创建日期对象2. 格式化日期3. 解析日期字符串4. 操作日期5. 比较日期 三、Day.js的高级功能1. 插件机制2. 国际化支持 四、实际应用案例1. 事件倒计时2. 日历应用 在JavaScript开发中…...

AI算法与图像处理 | 吴恩达团队新作!多模态方向

本文来源公众号“AI算法与图像处理”&#xff0c;仅用于学术分享&#xff0c;侵权删&#xff0c;干货满满。 原文链接&#xff1a;吴恩达团队新作&#xff01;多模态方向 研究评估了先进多模态基础模型在 10 个数据集上的多样本上下文学习&#xff0c;揭示了持续的性能提升。…...

云服务器Ubuntu18.04进行Nginx配置

云服务器镜像版本信息&#xff1a;Ubuntu 18.04 server 64bit&#xff0c;本文记录了在改版本镜像上安装Nginx&#xff0c;并介绍了Nginx配置文件目录&#xff0c;便于后面再次有需求时进行复习。 文章目录 Nginx的安装Nginx配置文件分析 Nginx的安装 1.执行下面命令进行安装…...

SQL labs-SQL注入(四,sqlmap对于post传参方式的注入)

本文仅作为学习参考使用&#xff0c;本文作者对任何使用本文进行渗透攻击破坏不负任何责任。 序言&#xff1a;本文主要讲解基于SQL labs靶场&#xff0c;sqlmap工具进行的post传参方式的SQL注入。 传参方式有两类&#xff0c;一类是直接在url栏内进行url编码后进行的传参&am…...

R包:plot1cell单细胞可视化包

介绍 plot1cell是用于单细胞数据seurat数据对象的可视化包。 安装 ## You might need to install the dependencies below if they are not available in your R library. bioc.packages <- c("biomaRt","GenomeInfoDb","EnsDb.Hsapiens.v86&qu…...

调用支付宝接口响应40004 SYSTEM_ERROR问题排查

在对接支付宝API的时候&#xff0c;遇到了一些问题&#xff0c;记录一下排查过程。 Body:{"datadigital_fincloud_generalsaas_face_certify_initialize_response":{"msg":"Business Failed","code":"40004","sub_msg…...

MongoDB学习和应用(高效的非关系型数据库)

一丶 MongoDB简介 对于社交类软件的功能&#xff0c;我们需要对它的功能特点进行分析&#xff1a; 数据量会随着用户数增大而增大读多写少价值较低非好友看不到其动态信息地理位置的查询… 针对以上特点进行分析各大存储工具&#xff1a; mysql&#xff1a;关系型数据库&am…...

如何在看板中体现优先级变化

在看板中有效体现优先级变化的关键措施包括&#xff1a;采用颜色或标签标识优先级、设置任务排序规则、使用独立的优先级列或泳道、结合自动化规则同步优先级变化、建立定期的优先级审查流程。其中&#xff0c;设置任务排序规则尤其重要&#xff0c;因为它让看板视觉上直观地体…...

微信小程序 - 手机震动

一、界面 <button type"primary" bindtap"shortVibrate">短震动</button> <button type"primary" bindtap"longVibrate">长震动</button> 二、js逻辑代码 注&#xff1a;文档 https://developers.weixin.qq…...

【论文笔记】若干矿井粉尘检测算法概述

总的来说&#xff0c;传统机器学习、传统机器学习与深度学习的结合、LSTM等算法所需要的数据集来源于矿井传感器测量的粉尘浓度&#xff0c;通过建立回归模型来预测未来矿井的粉尘浓度。传统机器学习算法性能易受数据中极端值的影响。YOLO等计算机视觉算法所需要的数据集来源于…...

相机从app启动流程

一、流程框架图 二、具体流程分析 1、得到cameralist和对应的静态信息 目录如下: 重点代码分析: 启动相机前,先要通过getCameraIdList获取camera的个数以及id,然后可以通过getCameraCharacteristics获取对应id camera的capabilities(静态信息)进行一些openCamera前的…...

【HTTP三个基础问题】

面试官您好&#xff01;HTTP是超文本传输协议&#xff0c;是互联网上客户端和服务器之间传输超文本数据&#xff08;比如文字、图片、音频、视频等&#xff09;的核心协议&#xff0c;当前互联网应用最广泛的版本是HTTP1.1&#xff0c;它基于经典的C/S模型&#xff0c;也就是客…...

DeepSeek 技术赋能无人农场协同作业:用 AI 重构农田管理 “神经网”

目录 一、引言二、DeepSeek 技术大揭秘2.1 核心架构解析2.2 关键技术剖析 三、智能农业无人农场协同作业现状3.1 发展现状概述3.2 协同作业模式介绍 四、DeepSeek 的 “农场奇妙游”4.1 数据处理与分析4.2 作物生长监测与预测4.3 病虫害防治4.4 农机协同作业调度 五、实际案例大…...

有限自动机到正规文法转换器v1.0

1 项目简介 这是一个功能强大的有限自动机&#xff08;Finite Automaton, FA&#xff09;到正规文法&#xff08;Regular Grammar&#xff09;转换器&#xff0c;它配备了一个直观且完整的图形用户界面&#xff0c;使用户能够轻松地进行操作和观察。该程序基于编译原理中的经典…...

docker 部署发现spring.profiles.active 问题

报错&#xff1a; org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property spring.profiles.active imported from location class path resource [application-test.yml] is invalid in a profile specific resource [origin: class path re…...