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

java:实现查询MySQL数据库中的数据,并导出excel、pdf类型文档(超详细)

查询MySQL数据库中数据,导出excel、pdf类型文档

1.数据库表格

CREATE TABLE `user` (`id` int NOT NULL AUTO_INCREMENT COMMENT '编号',`name` varchar(255) DEFAULT NULL COMMENT '姓名',`age` int DEFAULT NULL COMMENT '年龄',`addr` varchar(255) DEFAULT NULL COMMENT '住址1',`addr2` varchar(255) DEFAULT NULL COMMENT '住址2',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户表';

2.pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.example</groupId><artifactId>net</artifactId><version>0.0.1-SNAPSHOT</version><name>net</name><description>net</description><properties><java.version>1.8</java.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><spring-boot.version>2.6.13</spring-boot.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.2.2</version></dependency><dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><scope>runtime</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>
<!--        pdf--><dependency><groupId>com.itextpdf</groupId><artifactId>itextpdf</artifactId><version>5.5.13</version> <!-- 或使用最新版本 --></dependency><!-- pdf输出中文要用的jar --><dependency><groupId>com.itextpdf</groupId><artifactId>itext-asian</artifactId><version>5.2.0</version></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>${spring-boot.version}</version><type>pom</type><scope>import</scope></dependency>
<!--   excel表格导出--><dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.17</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>3.17</version></dependency><dependency><groupId>org.xmlunit</groupId><artifactId>xmlunit-core</artifactId></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>${spring-boot.version}</version><configuration><mainClass>com.example.net.NetApplication</mainClass><skip>true</skip></configuration><executions><execution><id>repackage</id><goals><goal>repackage</goal></goals></execution></executions></plugin></plugins></build></project>

3.User.java

package com.example.net.demos.entity;import lombok.Data;@Data
public class User {private Integer id;private String name;private Integer age;private String addr;private String addr2;
}

4.UserMapper.java

package com.example.net.demos.mapper;import com.example.net.demos.entity.User;
import org.apache.ibatis.annotations.Mapper;import java.util.List;@Mapper
public interface UserMapper {List<User> selectList();
}

5.UserMapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.net.demos.mapper.UserMapper"><resultMap id="user" type="com.example.net.demos.entity.User"><id column="id" property="id"/><result column="name" property="name"/><result column="age" property="age"/><result column="addr" property="addr"/><result column="addr2" property="addr2"/></resultMap><select id="selectList" resultMap="user">select * from user</select>
</mapper>

6.service

6.1 UserService.java

package com.example.net.demos.service;import com.example.net.demos.entity.User;
import org.apache.ibatis.annotations.Mapper;import java.util.List;@Mapper
public interface UserService {List<User> selectAll();
}

6.2 UserServiceImpl.java

package com.example.net.demos.service.impl;import com.example.net.demos.entity.User;
import com.example.net.demos.mapper.UserMapper;
import com.example.net.demos.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;@Service
public class UserServiceImpl implements UserService {@AutowiredUserMapper userMapper;@Overridepublic List<User> selectAll() {return userMapper.selectList();}
}

7.UserController

package com.example.net.demos.controller;import com.example.net.demos.entity.User;
import com.example.net.demos.service.UserService;
import com.example.net.demos.util.PageUtil;
import com.example.net.demos.util.PdfFUtil;
import com.example.net.demos.util.R;
import com.itextpdf.text.Document;
import com.itextpdf.text.Font;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;import java.io.File;
import java.io.FileOutputStream;
import java.util.List;@RestController
@RequestMapping("/user")
public class UserController {private Logger logger= LoggerFactory.getLogger(UserController.class);@AutowiredUserService userService;/*** 查询所有数据* @return*/@PostMapping("/list")public R selectList(){List<User> users = userService.selectAll();logger.info(users.toString());return R.ok(users);}/*** 导出pdf格式文档* @param destination* @return* @throws Exception*/@PostMapping("/pdf")public List<User> getUser(@RequestParam("destination") String destination) throws Exception {List<User> list=userService.selectAll();long currentTime=System.currentTimeMillis();int total=list.size();try {
//            1.新建document对象Document document = new Document(PageSize.A4.rotate());  //建立一个Document对象
//            pdf文档存储的地址String savePath=destination+"/"+"user_"+currentTime+".pdf";//            2.建立一个书写器(writer)与document对象关联File file = new File(savePath);  //修改要生成pdf的位置路径file.createNewFile();PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));//            3.打开文档document.open();//            标题Paragraph paragraph = new Paragraph("用户表", titlefont_16);paragraph.setAlignment(1); //设置文字居中,0靠左,1居中,2靠右paragraph.setIndentationLeft(12); //设置左缩进paragraph.setIndentationRight(12);  //设置右缩进paragraph.setFirstLineIndent(24); //设置首行缩进paragraph.setLeading(20f);  //设置行间距paragraph.setSpacingBefore(5f);  //设置段落上空白paragraph.setSpacingAfter(10f);  //设置段落下空白document.add(paragraph);   //标题int pn = 1;int ps = 34;for (int j = 0; j < (total / ps) + 1; j++) {PageUtil pageUtil1 = new PageUtil();List<User> listPage=pageUtil1.pageUtil(list,pn,ps);
//                表格PdfPTable table = PdfFUtil.createTable(new float[]{75, 110, 75, 140,75});table.addCell(PdfFUtil.createCell("ID",textfont_10));table.addCell(PdfFUtil.createCell("姓名",textfont_10));table.addCell(PdfFUtil.createCell("年龄",textfont_10));table.addCell(PdfFUtil.createCell("住址",textfont_10));table.addCell(PdfFUtil.createCell("住址2",textfont_10));for (int i = 0; i < listPage.size(); i++) {table.addCell(PdfFUtil.createCell(String.valueOf(listPage.get(i).getId()), textfont_10));table.addCell(PdfFUtil.createCell(listPage.get(i).getName(), textfont_10));table.addCell(PdfFUtil.createCell(String.valueOf(listPage.get(i).getAge()), textfont_10));table.addCell(PdfFUtil.createCell(String.valueOf(listPage.get(i).getAddr()), textfont_10));table.addCell(PdfFUtil.createCell(String.valueOf(listPage.get(i).getAddr2()), textfont_10));}document.add(table);PdfFUtil.onEndPage(writer, document);pn++;ps = 36;}
//            5.关闭文档document.close();}catch (Exception e){e.printStackTrace();}return null;}/*** 全局变量*/
//    定义全局的字体静态变量private static Font titlefont_16;private static Font titlefontnormal_16;private static Font headfont_14;private static Font headfontnormal_14;private static Font headfont_12;private static Font headfontnormal_12;private static Font keyfont_10;private static Font textfont_10;private static Font underlinefont_10;
//    静态代码块static{try{BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);titlefont_16=new Font(bfChinese,16,Font.BOLD);headfont_14=new Font(bfChinese,14,Font.BOLD);headfont_12=new Font(bfChinese,12,Font.BOLD);keyfont_10=new Font(bfChinese,10,Font.BOLD);titlefontnormal_16=new Font(bfChinese,16,Font.NORMAL);headfontnormal_14=new Font(bfChinese,14,Font.NORMAL);headfontnormal_12=new Font(bfChinese,12,Font.NORMAL);textfont_10=new Font(bfChinese,10, Font.NORMAL);underlinefont_10=new Font(bfChinese,10,Font.UNDERLINE);}catch (Exception e){e.printStackTrace();}}/*** 导出excel表格* @param response* @throws Exception*/@PostMapping("/excel")public void downloadExcel(HttpServletResponse response) throws Exception {
//        创建HSSFWorkbook对象,excel的文档对象HSSFWorkbook workbook = new HSSFWorkbook();
//        excel的表单HSSFSheet sheet = workbook.createSheet("用户表");//        数据库表中的数据List<User> list=userService.selectAll();//        设置要导出的文件名String fileName="user"+".xls";
//        新增数据行,并且设置单元格数据int rowNum=1;String[] headers={"ID","姓名","年龄","住址","住址2"};
//        headers 标识excel表中第一行的表头HSSFRow row = sheet.createRow(0);
//        在excel表中添加表头for(int i=0;i<headers.length;i++){HSSFCell cell=row.createCell(i);HSSFRichTextString text=new HSSFRichTextString(headers[i]);cell.setCellValue(text);}
//        在表头中存放查询到的数据放入对应的列for(User user:list){HSSFRow row1=sheet.createRow(rowNum);row1.createCell(0).setCellValue(user.getId());row1.createCell(1).setCellValue(user.getName());row1.createCell(2).setCellValue(user.getAge());row1.createCell(3).setCellValue(user.getAddr());row1.createCell(4).setCellValue(user.getAddr2());rowNum++;}response.setContentType("application/octet-stream");response.setHeader("Content-disposition", "attachment;filename=" + fileName);response.flushBuffer();workbook.write(response.getOutputStream());}
}

8.工具类

8.1 PageUtil.java

package com.example.net.demos.util;import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;public class PageUtil<T> implements Serializable {/*** 实体类列表*/private List<T> content;/*** 是否首页*/private boolean first;/*** 是否尾页*/private boolean last;/*** 总记录数*/private Integer totalCount;/*** 总页数*/private Integer totalPages;/*** 当前页记录数*/private Integer count;/*** 每页记录数*/private Integer pageSize;/*** 当前页*/private Integer pageNum;@Overridepublic String toString() {return "PageUtil{" +"content=" + content +", first=" + first +", last=" + last +", totalCount=" + totalCount +", totalPages=" + totalPages +", count=" + count +", pageSize=" + pageSize +", pageNum=" + pageNum +'}';}public Integer getTotalCount() {return totalCount;}public void setTotalCount(Integer totalCount) {this.totalCount = totalCount;}public Integer getCount() {return count;}public void setCount(Integer count) {this.count = count;}public void setContent(List<T> content) {this.content = content;}public void setFirst(boolean first) {this.first = first;}public void setLast(boolean last) {this.last = last;}public void setTotalPages(Integer totalPages) {this.totalPages = totalPages;}public void setPageSize(Integer pageSize) {this.pageSize = pageSize;}public void setPageNum(Integer pageNum) {this.pageNum = pageNum;}public List<T> getContent() {return content;}public boolean isFirst() {return first;}public boolean isLast() {return last;}public Integer getTotalPages() {return totalPages;}public Integer getPageSize() {return pageSize;}public Integer getPageNum() {return pageNum;}//public List<T> pageUtil(Integer page, Integer size, List<T> list) {public List<T> pageUtil( List<T> list,Integer page, Integer size) {page = page <= 0 ? 1 : page;List<T> list1 = list.stream().skip((page - 1) * size).limit(size).collect(Collectors.toList());int length = list.size();//是否第一页this.first = (page == 1);//是否最后一页this.last = (page == (length - 1) / size);//总页数this.totalPages = ((length - 1) / size + 1);//总elementsthis.totalCount = (length);//每页多少elementsthis.pageSize = (size);//内容this.content = (list1);//当前页数据量this.count = (list1.size());//当前页数,第一页是1this.pageNum = (page);return list1;}}

8.2 PdfFUtil.java

package com.example.net.demos.util;import com.itextpdf.text.*;
import com.itextpdf.text.pdf.*;import java.io.IOException;public class PdfFUtil {// 最大宽度private static int maxWidth = 720;/**------------------------创建表格单元格的方法start----------------------------*//*** 创建单元格(指定字体)** @param value* @param font* @return*/public static PdfPCell createCell(String value, Font font) {PdfPCell cell = new PdfPCell();cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中cell.setPhrase(new Phrase(value, font));return cell;}/*** 创建单元格(指定字体、设置单元格高度)** @param value* @param font* @return 申请事由——这行使用的方法*/public static PdfPCell createCell(String value, Font font, float f) {PdfPCell cell = new PdfPCell();cell.setVerticalAlignment(Element.ALIGN_MIDDLE);cell.setHorizontalAlignment(Element.ALIGN_CENTER);cell.setPhrase(new Phrase(value, font));cell.setFixedHeight(f); // 设置表格中的单行高度return cell;}/*** 创建单元格(指定字体、水平局左/中/右)** @param value* @param font* @param align* @return*/public static PdfPCell createCell(String value, Font font, int align) {PdfPCell cell = new PdfPCell();cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中cell.setHorizontalAlignment(align); //水平居中cell.setPhrase(new Phrase(value, font));return cell;}/*** 创建单元格(指定字体、水平局左/中/右、单元格跨x列合并)** @param value* @param font* @param align* @param colspan* @return*/public PdfPCell createCell(String value, Font font, int align, int colspan) {PdfPCell cell = new PdfPCell();cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中cell.setHorizontalAlignment(align); //水平居中cell.setColspan(colspan);cell.setPhrase(new Phrase(value, font));return cell;}/*** 创建单元格(指定字体、水平居..、单元格跨x列合并、设置单元格内边距)** @param value* @param font* @param align* @param colspan* @param boderFlag* @return*/public static PdfPCell createCell(String value, Font font, int align, int colspan, boolean boderFlag) {PdfPCell cell = new PdfPCell();cell.setVerticalAlignment(Element.ALIGN_MIDDLE);cell.setHorizontalAlignment(align);cell.setColspan(colspan);cell.setPhrase(new Phrase(value, font));cell.setPadding(3.0f);if (!boderFlag) {cell.setBorder(0);cell.setPaddingTop(10.0f);cell.setPaddingBottom(7.0f);} else if (boderFlag) {cell.setBorder(0);cell.setPaddingTop(0.0f);cell.setPaddingBottom(15.0f);}return cell;}/*** 创建单元格(指定字体、水平..、边框宽度:0表示无边框、内边距)** @param value* @param font* @param align* @param borderWidth* @param paddingSize* @param flag* @return*/public static PdfPCell createCell(String value, Font font, int align, float[] borderWidth, float[] paddingSize, boolean flag) {PdfPCell cell = new PdfPCell();cell.setVerticalAlignment(Element.ALIGN_MIDDLE);cell.setHorizontalAlignment(align);cell.setPhrase(new Phrase(value, font));cell.setBorderWidthLeft(borderWidth[0]);cell.setBorderWidthRight(borderWidth[1]);cell.setBorderWidthTop(borderWidth[2]);cell.setBorderWidthBottom(borderWidth[3]);cell.setPaddingTop(paddingSize[0]);cell.setPaddingBottom(paddingSize[1]);if (flag) {cell.setColspan(2);}return cell;}
/**------------------------创建表格单元格的方法end----------------------------*//**--------------------------创建表格的方法start----------------------------*//*** 创建默认列宽,指定列数、水平(居中、右、左)的表格** @param colNumber* @param align* @return*/public PdfPTable createTable(int colNumber, int align) {PdfPTable table = new PdfPTable(colNumber);try {table.setTotalWidth(maxWidth);table.setLockedWidth(true);table.setHorizontalAlignment(align);table.getDefaultCell().setBorder(1);} catch (Exception e) {e.printStackTrace();}return table;}/*** 创建指定列宽、列数的表格** @param widths* @return*/public static PdfPTable createTable(float[] widths) {PdfPTable table = new PdfPTable(widths);try {table.setTotalWidth(maxWidth);table.setLockedWidth(true);table.setHorizontalAlignment(Element.ALIGN_CENTER);table.getDefaultCell().setBorder(1);} catch (Exception e) {e.printStackTrace();}return table;}/*** 创建空白的表格** @return*/public PdfPTable createBlankTable() throws IOException, DocumentException {BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);Font keyfont = new Font(bfChinese, 10, Font.BOLD);PdfPTable table = new PdfPTable(1);table.getDefaultCell().setBorder(0);table.addCell(createCell("", keyfont));table.setSpacingAfter(20.0f);table.setSpacingBefore(20.0f);return table;}
/**--------------------------创建表格的方法end----------------------------*//*** --------------------------页码方法start----------------------------*/public static void onEndPage(PdfWriter writer, Document document) throws IOException, DocumentException {PdfContentByte cb = writer.getDirectContent();PdfTemplate tpl; // 页码模板用来固定显示数据BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);tpl = writer.getDirectContent().createTemplate(100, 100);cb.saveState();String text = "第" + writer.getPageNumber() + "页";cb.beginText();cb.setFontAndSize(bfChinese, 8);cb.setTextMatrix(480, 35);//定位“第x页” 在具体的页面调试时候需要更改这xy的坐标cb.showText(text);cb.endText();//** 创建以及固定显示总页数的位置cb.addTemplate(tpl, 283, 10);//定位“y页” 在具体的页面调试时候需要更改这xy的坐标cb.stroke();cb.restoreState();cb.closePath();
/**--------------------------页码方法end----------------------------*/}
}

8.3 R.java

package com.example.net.demos.util;import java.io.Serializable;public class R<T> implements Serializable {/*** 成功*/public static final int SUCCESS = 200;/*** 失败*/public static final int FAIL = 500;private static final long serialVersionUID = 1L;private int code;private String msg;private T data;public static <T> R<T> ok() {return restResult(null, SUCCESS, "操作成功");}public static <T> R<T> ok(T data) {return restResult(data, SUCCESS, "操作成功");}public static <T> R<T> ok(T data, String msg) {return restResult(data, SUCCESS, msg);}public static <T> R<T> fail() {return restResult(null, FAIL, "操作失败");}public static <T> R<T> fail(String msg) {return restResult(null, FAIL, msg);}public static <T> R<T> fail(T data) {return restResult(data, FAIL, "操作失败");}public static <T> R<T> fail(T data, String msg) {return restResult(data, FAIL, msg);}public static <T> R<T> fail(int code, String msg) {return restResult(null, code, msg);}private static <T> R<T> restResult(T data, int code, String msg) {R<T> apiResult = new R<>();apiResult.setCode(code);apiResult.setData(data);apiResult.setMsg(msg);return apiResult;}public static <T> Boolean isError(R<T> ret) {return !isSuccess(ret);}public static <T> Boolean isSuccess(R<T> ret) {return R.SUCCESS == ret.getCode();}public int getCode() {return code;}public void setCode(int code) {this.code = code;}public String getMsg() {return msg;}public void setMsg(String msg) {this.msg = msg;}public T getData() {return data;}public void setData(T data) {this.data = data;}
}

相关文章:

java:实现查询MySQL数据库中的数据,并导出excel、pdf类型文档(超详细)

查询MySQL数据库中数据&#xff0c;导出excel、pdf类型文档 1.数据库表格 CREATE TABLE user (id int NOT NULL AUTO_INCREMENT COMMENT 编号,name varchar(255) DEFAULT NULL COMMENT 姓名,age int DEFAULT NULL COMMENT 年龄,addr varchar(255) DEFAULT NULL COMMENT 住址1…...

Java后端须知的前端知识

Java后端须知的前端知识 HTML &#xff08;超文本标记语言&#xff09; W3C标准 结构&#xff1a;HTML表现&#xff1a;CSS行为&#xff1a;JavaScript 快速入门 <html><head><title></title></head><body><font color"red&q…...

Servlet基础之URL匹配规则

文章目录 URL 匹配规则几个容易混淆的规则精确匹配路径匹配扩展名匹配缺省匹配注意事项 1&#xff1a;匹配规则不能混用注意事项 2&#xff1a;"\/\*" 和 "/" 含义并不相同 URL 匹配规则 几个容易混淆的规则 servlet 容器中的匹配规则既不是简单的通配&am…...

【面试真题】Javascript 实现多条件过滤数组

场景&#xff1a; 有这么一个数组 [{a,123,b:345,c:456,d:t12},{a,234,b:345,c:thf2,d:t12}], 现在希望能够通过逗号分隔搜索值的输入方式&#xff0c;从数组中过滤出模糊匹配的数组元素。 解析&#xff1a; 可以使用 JavaScript 的 filter 函数和 indexOf 函数来实现这个功…...

spark广播变量

2024-1-24 广播变量特点 Broadcast Variable会将使用到的变量&#xff0c;只会为每个节点拷贝一份&#xff0c;不会为每个task进行拷贝&#xff0c;能够优化性能&#xff08;在task数量比较大体现更明显&#xff09;&#xff0c;减少网络传输及内存消耗通过SparkContext的bro…...

如何让wordpress首页只显示某一篇文章全部内容?在您的主页显示选择

大多数WordPress站点首页默认都是显示最新发布的文章列表&#xff0c;不过有些站点比较特殊&#xff0c;只想显示某一篇文章的全部内容&#xff0c;那么应该怎么设置呢&#xff1f; 其实&#xff0c;WordPress后台 >> 设置 >> 阅读 >> 在“您的主页显示”中…...

Git怎样用?(下载到本地,和在本地初始化)

全局设置&#xff1a; 点击第二个 输入&#xff1a; 例如&#xff1b;邮箱是随意地 git config --global user.name "名字" git config --global user.email "邮箱" 获取git仓库 本地初始化&#xff1a; 创建仓库 右键第二个 输入 git init 克隆&#…...

JVM基础知识汇总篇

☆* o(≧▽≦)o *☆嗨~我是小奥&#x1f379; &#x1f4c4;&#x1f4c4;&#x1f4c4;个人博客&#xff1a;小奥的博客 &#x1f4c4;&#x1f4c4;&#x1f4c4;CSDN&#xff1a;个人CSDN &#x1f4d9;&#x1f4d9;&#x1f4d9;Github&#xff1a;传送门 &#x1f4c5;&a…...

马哈鱼SQLFlow Lite的python版本

Gudu SQLFlow 是一款用来分析各种数据库的 SQL 语句和存储过程来获取复杂的数据血缘关系并进行可视化的工具。 Gudu SQLFlow Lite version for python 可以让 python 开发者把数据血缘分析和可视化能力快速集成到他们自己的 python 应用中。 Gudu SQLFlow Lite version for p…...

【原创】VMware创建子网,并使用软路由获得访问互联网的能力,并通过静态路由让上层网络访问位于虚拟机的子网

前言 一看标题就很离谱&#xff0c;确实内容也有点复杂&#xff0c;我的初衷是为后面搞软路由做准备&#xff0c;先通过VMware进行可行性验证&#xff0c;确定方案是否可行&#xff0c;再做下一步的计划。结论当然可以的&#xff0c;能通能访问&#xff0c;强的不行。 网络拓…...

华为和思科各数通设备的常用命令

本文基于华为和思科各数通设备的常用命令来对比学习,这两个命令体系是网络项目中常见的,其他一些厂家也是基于类似的命令体系.下面也会根据公司业务需求列举部分网络设备厂家,比如H3C,盛科的命令不同之处. 1. 查看命令 华为: <Quidway>dis cur …...

Qt Excel读写 - QXlsx的安装配置以及测试

Qt Excel读写 - QXlsx的安装配置以及测试 引言一、安装配置二、简单测试 引言 Qt无自带的库处理Excel 文件&#xff0c;但可通过QAxObject 借助COM接口进行Excel的读写1。亦可使用免费的开源第三方库&#xff1a;QXlsx&#xff0c;一个基于Qt库开发的用于读写Microsoft Excel文…...

【报错处理】ModuleNotFoundError: No module named ‘paddle.fluid‘

引言 在使用 UIE&#xff08;统一信息提取&#xff09;模型时&#xff0c;您可能会遇到错误消息 "ModuleNotFoundError: No module named paddle.fluid"。这个错误可能让人沮丧&#xff0c;但通常很容易解决。在本博客文章中&#xff0c;我将为您介绍解决此问题。 一…...

Wpf 使用 Prism 实战开发Day16

客户端使用RestSharp库调用WebApi 动态加载数据 在MyDoTo客户端中&#xff0c;使用NuGet 安装两个库 RestSharp Newtonsoft.Json 一. RestSharp 简单的使用测试例子 当前章节主要目的是&#xff1a;对RestSharp 库&#xff0c;根据项目需求再次进行封装。下面先做个简单的使用…...

八斗学习笔记

1 初始环境安装 Anaconda安装(一款可以同时创建跟管理多个python环境的软件) https://blog.csdn.net/run_success/article/details/134656460 Anaconda创建一个新python环境(安装人工智能常用的第三方python包&#xff0c;如&#xff1a;tensorflow、keras、pytorch) https://…...

【Uni-App】Vuex在vue3版本中的使用与持久化

Vuex是什么 Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式。它采用集中式存储管理应用的所有组件的状态&#xff0c;并以相应的规则保证状态以一种可预测的方式发生变化。 简而言之就是用来存数据&#xff0c;可以有效减少使用组件传参出现的问题。 基本元素&#xff1a;…...

基于Qt 音乐播放器mp3(进阶)

​## 项目工具 工具名QtQt 5.14.2图标设计Adobe Ai音频素材剪映平台windowsgif录制ScreenGif录屏Win10 自带录屏 Win + G## 项目演示 先点击构建项目,项目构建完成后,再将本例的 myMusic 歌曲文件夹拷贝到可执行程序...

力扣唯一元素的和

题目&#xff1a; 给你一个整数数组 nums 。数组中唯一元素是那些只出现 恰好一次 的元素。 请你返回 nums 中唯一元素的 和 。 示例 1&#xff1a; 输入&#xff1a;nums [1,2,3,2] 输出&#xff1a;4 解释&#xff1a;唯一元素为 [1,3] &#xff0c;和为 4 。示例 2&#xf…...

力扣(leetcode)第169题多数元素(Python)

169.多数元素 题目链接&#xff1a;169.多数元素 给定一个大小为 n 的数组 nums &#xff0c;返回其中的多数元素。多数元素是指在数组中出现次数 大于 ⌊ n/2 ⌋ 的元素。 你可以假设数组是非空的&#xff0c;并且给定的数组总是存在多数元素。 示例 1&#xff1a; 输入&am…...

springBoot - mybatis 多数据源实现方案

应用场景: 多数据源 小型项目 或者 大项目的临时方案中比较常用.在日常开发中,可能我们需要查询多个数据库,但是数据库实例不同,导致不能通过 指定schema的方式 区分不同的库, 这种情况下就需要我们应用程序配置多数据源 实现方式: 首先自定义实现 datasource数据源 为当前…...

unity 讯飞webapi在线语音合成

websocker插件使用的unitywebsocker 讯飞webapi&#xff0c;连接后只能请求一次&#xff0c;所以每次使用时进行连接&#xff0c;连接成功后进行请求&#xff0c;请求完成后关闭连接。 为什么连接后只能请求一次呢&#xff0c;可能是方便统计使用量。 如何通过音频数据计算出…...

[NCTF2019]Fake XML cookbook(特详解)

先试了一下弱口令&#xff0c;哈哈习惯了 查看页面源码发现xml function doLogin(){var username $("#username").val();var password $("#password").val();if(username "" || password ""){alert("Please enter the usern…...

腾讯云SDK并发调用优化方案

目录 一、概述 二、 网关的使用 2.1 核心代码 三、腾讯云SDK依赖包的改造 一、概述 此网关主要用于协调腾讯云SDK调用的QPS消耗&#xff0c;使得多个腾讯云用户资源能得到最大限度的利用。避免直接使用腾讯云SDK 时&#xff0c;在较大并发情况下导致接口调用异常。网关的工…...

【排序算法】C语言实现随机快排,巨详细讲解

文章目录 &#x1f680;前言&#x1f680;快排的核心过程partition&#xff08;划分过程&#xff09;&#x1f680;快排1.0&#x1f680;随机快速排序&#x1f680;稳定性 &#x1f680;前言 铁子们好啊&#xff01;继续我们排序算法今天要讲的是快排&#xff0c;通常大家所说…...

Java强训day13(选择题编程题)

选择题 编程题 题目1 import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);String s sc.nextLine();char[] c s.toCharArray();int i 0;int t 0;while (i < c.length) {if (c[i] ! \") {…...

搭建WebGL开发环境

前言 本篇文章介绍如何搭建WebGL开发环境 WebGL WebGL的技术规范继承自免费和开源的OpenGL ES标准&#xff0c;从某种意义上说&#xff0c;WebGL就是Web版的OpenGL ES&#xff0c;而OpenGL ES是从OpenGL中派生出来的。他们的应用环境有区别&#xff0c;一般来说&#xff1a;…...

学习嵌入式第十五天之结构体

用变量a给出下面的定义 a) 一个整型数&#xff08;An integer&#xff09; //int a;b) 一个指向整型数的指针&#xff08;A pointer to an integer&#xff09; //int *a;c) 一个指向指针的的指针&#xff0c;它指向的指针是指向一个整型数&#xff08;A pointer to a poin…...

【HDFS】一天一个RPC系列--updateBlockForPipeline

本文目标是: 弄清updateBlockForPipeline这个RPC的作用。弄清updateBlockForPipeline RPC的使用场景,代码里的调用点。一、updateBlockForPipeline的作用 其定义在ClientProtocol接口里,是Client与NameNode之间的接口。 看其代码注释描述: 为一个under construction状态下…...

测试面试题(0101设计测试用例关键)

1. 测试计划 测试范围&#xff0c;本次改动的模块&#xff0c;新增了哪些功能测试策略&#xff0c;包含测试依据&#xff0c;测试准入标准&#xff0c;准出标准&#xff0c;测试重点及方法&#xff08;确认功能的优先级&#xff09;&#xff0c;测试工具的选择测试管理&#x…...

C++ 数论相关题目:高斯消元解异或线性方程组

输入一个包含 n 个方程 n 个未知数的异或线性方程组。 方程组中的系数和常数为 0 或 1 &#xff0c;每个未知数的取值也为 0 或 1 。 求解这个方程组。 异或线性方程组示例如下&#xff1a; M[1][1]x[1] ^ M[1][2]x[2] ^ … ^ M[1][n]x[n] B[1] M[2][1]x[1] ^ M[2][2]x[2]…...