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

基于jackson封装的json字符串与javaBean对象转换工具

文章目录

  • 一、概述
  • 二、编码实现
    • 1. pom文件引入组件
    • 2. 核心代码
  • 三、功能测试
    • 1. 测试文件
    • 2. 测试代码
  • 四,完整代码

一、概述

带有API接口交互的web项目开发过程中,json字符串与javaBean对象之间的相互转换是比较常见的需求,基于jackson ObjectMapper 实现的工具类较好的满足了此需求。

二、编码实现

1. pom文件引入组件

<dependency><groupId>org.springframework</groupId><artifactId>spring-webflux</artifactId><version>5.2.3.RELEASE</version></dependency><dependency><groupId>io.projectreactor.netty</groupId><artifactId>reactor-netty</artifactId><version>0.9.4.RELEASE</version></dependency><dependency><groupId>org.apache.logging.log4j</groupId><artifactId>log4j-slf4j-impl</artifactId><version>2.12.1</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.10.2</version></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.10</version></dependency><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.5</version></dependency><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-api</artifactId><version>5.5.2</version><scope>test</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.12</version><scope>provided</scope></dependency>

2. 核心代码

JsonBeanUtils


import java.io.IOException;import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;/*** JsonBean转换工具* * @author 00fly**/
public class JsonBeanUtils
{private static ObjectMapper objectMapper = new ObjectMapper();/*** bean转json字符串* * @param bean* @return* @throws IOException*/public static String beanToJson(Object bean)throws IOException{String jsonText = objectMapper.writeValueAsString(bean);return objectMapper.readTree(jsonText).toPrettyString();}/*** json字符串转bean* * @param jsonText* @return* @throws IOException*/public static <T> T jsonToBean(String jsonText, Class<T> clazz)throws IOException{return objectMapper.readValue(jsonText, clazz);}/*** json字符串转bean* * @param jsonText* @return* @throws IOException*/public static <T> T jsonToBean(String jsonText, JavaType javaType)throws IOException{return objectMapper.readValue(jsonText, javaType);}/*** json字符串转bean* * @param jsonText* @return* @throws IOException*/public static <T> T jsonToBean(String jsonText, TypeReference<T> typeRef)throws IOException{return objectMapper.readValue(jsonText, typeRef);}
}

三、功能测试

1. 测试文件

jdbc.properties

druid.username=sa
druid.password=
druid.url=jdbc:h2:mem:hello;database_to_upper=false
druid.driverClassName=org.h2.Driver

data.json

{"code": 200,"message": "success","traceId": "fcd55497-864a-4d74-9db0-69a04655184f","data": {"list": [{"articleId": 135418954,"title": "java解析json复杂数据的两种思路","description": "萌新小明最近新开了CSDN博客,蠢蠢欲动,迫不及待的发表了几篇工作中积累下来的解决问题的涂鸦之作,看着访问量慢慢涨起来,心中暗暗窃喜。现在小明想每天23点记录一下每篇文章的访问量。。。","url": "https://blog.csdn.net/qq_16127313/article/details/135418954","type": 1,"top": false,"forcePlan": false,"viewCount": 828,"commentCount": 0,"editUrl": "https://editor.csdn.net/md?articleId=135418954","postTime": "2024-01-06 14:11:40","diggCount": 16,"formatTime": "前天 14:11","picList": ["https://img-blog.csdnimg.cn/direct/a409a0f4555c459fa05c00fd9ee0ea8c.png"],"collectCount": 19},{"articleId": 135244727,"title": "java lambda表达式训练题一","description": "Lambda 表达式,也可称为闭包,它是推动 Java 8 发布的最重要新特性。Lambda 允许把函数作为一个方法的参数(函数作为参数传递进方法中)。使用 Lambda 表达式可以使代码变的更加简洁紧凑。","url": "https://blog.csdn.net/qq_16127313/article/details/135244727","type": 1,"top": false,"forcePlan": false,"viewCount": 1238,"commentCount": 0,"editUrl": "https://editor.csdn.net/md?articleId=135244727","postTime": "2023-12-27 18:07:30","diggCount": 7,"formatTime": "2023.12.27","picList": ["https://img-blog.csdnimg.cn/direct/d59c68b950754e879914b5319cd1b53f.png"],"collectCount": 8},{"articleId": 135173565,"title": "二维码初体验 com.google.zxing 实现续 - web api封装","description": "在 二维码初体验 com.google.zxing 实现 我们实现了二维码的生成,但是大部分情况下,二维码的相关功能是作为API接口来提供服务的。我们下面便演示在springboot、Knife4j下封装api接口来实现二维码生成功能。如何使用下面的备份文件恢复成原始的项目代码,请移步查阅:神奇代码恢复工具-over-","url": "https://blog.csdn.net/qq_16127313/article/details/135173565","type": 1,"top": false,"forcePlan": false,"viewCount": 1904,"commentCount": 0,"editUrl": "https://editor.csdn.net/md?articleId=135173565","postTime": "2023-12-23 20:17:11","diggCount": 23,"formatTime": "2023.12.23","picList": ["https://img-blog.csdnimg.cn/direct/f0c994ca789a495a8c8c03d86d626f24.jpeg"],"collectCount": 23},{"articleId": 135167613,"title": "二维码初体验 com.google.zxing 实现","description": "Java 操作二维码的开源项目很多,如 SwetakeQRCode、BarCode4j、Zxing 等,这边以Zxing 为例进行介绍。选择需要生成QR原始文件,支持 “清除空白行及空格” 以减少二维码图片大小。支持输入文本内容,直接生成二维码代码结构QrCodeUI: 完整版本代码SimpleQrCodeUI:简化版本代码如何使用下面的备份文件恢复成原始的项目代码,请移步查阅:神奇代码恢复工具-over-","url": "https://blog.csdn.net/qq_16127313/article/details/135167613","type": 1,"top": false,"forcePlan": false,"viewCount": 1286,"commentCount": 0,"editUrl": "https://editor.csdn.net/md?articleId=135167613","postTime": "2023-12-23 13:52:23","diggCount": 6,"formatTime": "2023.12.23","picList": ["https://img-blog.csdnimg.cn/direct/d3eeac85857543869dce8967c570bdc4.jpeg"],"collectCount": 11},{"articleId": 135135799,"title": "【随笔】MD5加密字符串、文件apache、springframework实现","description": "【代码】【随笔】MD5加密字符串、文件commons-codec、springframework实现。","url": "https://blog.csdn.net/qq_16127313/article/details/135135799","type": 1,"top": false,"forcePlan": false,"viewCount": 1721,"commentCount": 0,"editUrl": "https://editor.csdn.net/md?articleId=135135799","postTime": "2023-12-21 17:29:54","diggCount": 9,"formatTime": "2023.12.21","picList": ["https://img-blog.csdnimg.cn/direct/dc26b7f1c731494f80c8c3b3badfa95d.jpeg"],"collectCount": 9}],"total": 72}
}

2. 测试代码


import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Properties;import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.type.TypeFactory;import lombok.Data;
import lombok.extern.slf4j.Slf4j;/*** JsonBeanUtils测试*/
@Slf4j
public class JsonBeanUtilsTest
{static String jsonText;static Properties properties;static WebClient webClient;static String url;@BeforeAllpublic static void init(){try{properties = PropertiesLoaderUtils.loadProperties(new ClassPathResource("jdbc.properties"));jsonText = IOUtils.toString(new ClassPathResource("data.json").getURL(), StandardCharsets.UTF_8);webClient = WebClient.builder().codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)).build();url = "https://blog.csdn.net/community/home-api/v1/get-business-list?page=1&size=5&businessType=blog&username=qq_16127313";}catch (IOException e){log.error(e.getMessage(), e);}}@Testpublic void propsTest()throws IOException{String propsJson = JsonBeanUtils.beanToJson(properties);log.info("propsJson : {} ", propsJson);log.info("properties: {} ", JsonBeanUtils.jsonToBean(propsJson, Properties.class));}@Testpublic void beanToJson001()throws IOException{BlogData blogData = JsonBeanUtils.jsonToBean(jsonText, BlogData.class);log.info("blogData: {} ", blogData);log.info("blogData: {} ", JsonBeanUtils.beanToJson(blogData));log.info("blogData.data: {} ", JsonBeanUtils.beanToJson(blogData.getData()));log.info("blogData.data.list: {} ", JsonBeanUtils.beanToJson(blogData.getData().getList()));}@Testpublic void beanToJson002()throws IOException{String resp = webClient.get().uri(url).acceptCharset(StandardCharsets.UTF_8).accept(MediaType.APPLICATION_JSON).retrieve().bodyToMono(String.class).block();BlogData blogData = JsonBeanUtils.jsonToBean(resp, BlogData.class);String jsonText = JsonBeanUtils.beanToJson(blogData);log.info("blogData: {} ", blogData);log.info("jsonText: {} ", jsonText);}/*** 测试 JsonBeanUtils.jsonToBean(String jsonText, JavaType javaType)* * @throws IOException*/@Testpublic void jsonToBean001()throws IOException{BlogData blogData = JsonBeanUtils.jsonToBean(jsonText, BlogData.class);String jsonStr = JsonBeanUtils.beanToJson(blogData.getData().getList());// List<SubList>JavaType javaType = TypeFactory.defaultInstance().constructParametricType(List.class, SubList.class);List<SubList> dataEntitys = JsonBeanUtils.jsonToBean(jsonStr, javaType);log.info("dataEntitys: {} ", dataEntitys);}/*** 测试 JsonBeanUtils.jsonToBean(String jsonText, TypeReference<T> typeRef)* * @throws IOException*/@Testpublic void jsonToBean002()throws IOException{BlogData blogData = JsonBeanUtils.jsonToBean(jsonText, BlogData.class);String jsonStr = JsonBeanUtils.beanToJson(blogData.getData().getList());// List<SubList>TypeReference<List<SubList>> typeRef = new TypeReference<List<SubList>>(){};List<SubList> dataEntitys = JsonBeanUtils.jsonToBean(jsonStr, typeRef);log.info("dataEntitys: {} ", dataEntitys);}
}@Data
class BlogData
{private Integer code;private String message;private String traceId;private Record data;
}@Data
class Record
{private List<SubList> list;private Long total;
}@Data
class SubList
{String articleId;String title;String description;String url;Integer type;String top;String forcePlan;Long viewCount;Long commentCount;String editUrl;String postTime;Long diggCount;String formatTime;Object picList;Long collectCount;
}

四,完整代码

如何使用下面的备份文件恢复成原始的项目代码,请移步查阅:神奇代码恢复工具

//goto 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.fly</groupId><artifactId>base</artifactId><version>0.0.1</version><name>base</name><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><java.version>1.8</java.version><skipTests>true</skipTests></properties><dependencies><dependency><groupId>org.springframework</groupId><artifactId>spring-webflux</artifactId><version>5.2.3.RELEASE</version></dependency><dependency><groupId>io.projectreactor.netty</groupId><artifactId>reactor-netty</artifactId><version>0.9.4.RELEASE</version></dependency><dependency><groupId>org.apache.logging.log4j</groupId><artifactId>log4j-slf4j-impl</artifactId><version>2.12.1</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.10.2</version></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.10</version></dependency><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.5</version></dependency><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-api</artifactId><version>5.5.2</version><scope>test</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.12</version><scope>provided</scope></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.10.1</version><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin></plugins></build>
</project>
//goto src\main\java\com\fly\core\utils\JsonBeanUtils.java
package com.fly.core.utils;import java.io.IOException;import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;/*** JsonBean转换工具* * @author 00fly**/
public class JsonBeanUtils
{private static ObjectMapper objectMapper = new ObjectMapper();/*** bean转json字符串* * @param bean* @return* @throws IOException*/public static String beanToJson(Object bean)throws IOException{String jsonText = objectMapper.writeValueAsString(bean);return objectMapper.readTree(jsonText).toPrettyString();}/*** json字符串转bean* * @param jsonText* @return* @throws IOException*/public static <T> T jsonToBean(String jsonText, Class<T> clazz)throws IOException{return objectMapper.readValue(jsonText, clazz);}/*** json字符串转bean* * @param jsonText* @return* @throws IOException*/public static <T> T jsonToBean(String jsonText, JavaType javaType)throws IOException{return objectMapper.readValue(jsonText, javaType);}/*** json字符串转bean* * @param jsonText* @return* @throws IOException*/public static <T> T jsonToBean(String jsonText, TypeReference<T> typeRef)throws IOException{return objectMapper.readValue(jsonText, typeRef);}
}
//goto src\main\resources\log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="off" monitorInterval="0"><appenders><console name="Console" target="system_out"><patternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" /></console></appenders><loggers><root level="INFO"><appender-ref ref="Console" /></root></loggers>
</configuration>
//goto src\test\java\com\fly\core\utils\JsonBeanUtilsTest.java
package com.fly.core.utils;import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Properties;import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.type.TypeFactory;import lombok.Data;
import lombok.extern.slf4j.Slf4j;/*** JsonBeanUtils测试*/
@Slf4j
public class JsonBeanUtilsTest
{static String jsonText;static Properties properties;static WebClient webClient;static String url;@BeforeAllpublic static void init(){try{properties = PropertiesLoaderUtils.loadProperties(new ClassPathResource("jdbc.properties"));jsonText = IOUtils.toString(new ClassPathResource("data.json").getURL(), StandardCharsets.UTF_8);webClient = WebClient.builder().codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)).build();url = "https://blog.csdn.net/community/home-api/v1/get-business-list?page=1&size=5&businessType=blog&username=qq_16127313";}catch (IOException e){log.error(e.getMessage(), e);}}@Testpublic void propsTest()throws IOException{String propsJson = JsonBeanUtils.beanToJson(properties);log.info("propsJson : {} ", propsJson);log.info("properties: {} ", JsonBeanUtils.jsonToBean(propsJson, Properties.class));}@Testpublic void beanToJson001()throws IOException{BlogData blogData = JsonBeanUtils.jsonToBean(jsonText, BlogData.class);log.info("blogData: {} ", blogData);log.info("blogData: {} ", JsonBeanUtils.beanToJson(blogData));log.info("blogData.data: {} ", JsonBeanUtils.beanToJson(blogData.getData()));log.info("blogData.data.list: {} ", JsonBeanUtils.beanToJson(blogData.getData().getList()));}@Testpublic void beanToJson002()throws IOException{String resp = webClient.get().uri(url).acceptCharset(StandardCharsets.UTF_8).accept(MediaType.APPLICATION_JSON).retrieve().bodyToMono(String.class).block();BlogData blogData = JsonBeanUtils.jsonToBean(resp, BlogData.class);String jsonText = JsonBeanUtils.beanToJson(blogData);log.info("blogData: {} ", blogData);log.info("jsonText: {} ", jsonText);}/*** 测试 JsonBeanUtils.jsonToBean(String jsonText, JavaType javaType)* * @throws IOException*/@Testpublic void jsonToBean001()throws IOException{BlogData blogData = JsonBeanUtils.jsonToBean(jsonText, BlogData.class);String jsonStr = JsonBeanUtils.beanToJson(blogData.getData().getList());// List<SubList>JavaType javaType = TypeFactory.defaultInstance().constructParametricType(List.class, SubList.class);List<SubList> dataEntitys = JsonBeanUtils.jsonToBean(jsonStr, javaType);log.info("dataEntitys: {} ", dataEntitys);}/*** 测试 JsonBeanUtils.jsonToBean(String jsonText, TypeReference<T> typeRef)* * @throws IOException*/@Testpublic void jsonToBean002()throws IOException{BlogData blogData = JsonBeanUtils.jsonToBean(jsonText, BlogData.class);String jsonStr = JsonBeanUtils.beanToJson(blogData.getData().getList());// List<SubList>TypeReference<List<SubList>> typeRef = new TypeReference<List<SubList>>(){};List<SubList> dataEntitys = JsonBeanUtils.jsonToBean(jsonStr, typeRef);log.info("dataEntitys: {} ", dataEntitys);}
}@Data
class BlogData
{private Integer code;private String message;private String traceId;private Record data;
}@Data
class Record
{private List<SubList> list;private Long total;
}@Data
class SubList
{String articleId;String title;String description;String url;Integer type;String top;String forcePlan;Long viewCount;Long commentCount;String editUrl;String postTime;Long diggCount;String formatTime;Object picList;Long collectCount;
}
//goto src\test\resources\jdbc.properties
druid.username=sa
druid.password=
druid.url=jdbc:h2:mem:hello;database_to_upper=false
druid.driverClassName=org.h2.Driver
//goto src\test\resources\log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="off" monitorInterval="0"><appenders><console name="Console" target="system_out"><patternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" /></console></appenders><loggers><root level="INFO"><appender-ref ref="Console" /></root></loggers>
</configuration>

有任何问题和建议,都可以向我提问讨论,大家一起进步,谢谢!

-over-

相关文章:

基于jackson封装的json字符串与javaBean对象转换工具

文章目录 一、概述二、编码实现1. pom文件引入组件2. 核心代码 三、功能测试1. 测试文件2. 测试代码 四&#xff0c;完整代码 一、概述 带有API接口交互的web项目开发过程中&#xff0c;json字符串与javaBean对象之间的相互转换是比较常见的需求&#xff0c;基于jackson Objec…...

js中的数据类型

JavaScript 中有以下几种常见的数据类型&#xff1a; 基本类型&#xff08;原始类型&#xff09;&#xff1a; 字符串&#xff08;String&#xff09;&#xff1a;表示文本数据。数字&#xff08;Number&#xff09;&#xff1a;表示数值数据。布尔&#xff08;Boolean&#xf…...

vue3+vant+cropper.js实现移动端图片裁剪功能

一、前言 最近做项目中遇到一个需求&#xff0c;需要对海报图片按照一定的比例进行裁剪并上传到oss。一开始这个需求思路有两个&#xff0c;使用canvas原生或者寻找现成的第三方库&#xff0c;对比了一番觉得canvas实现时间耗费较长&#xff0c;且秉承着不重复造轮子的原则&am…...

springCould中的Bus-从小白开始【11】

目录 &#x1f9c2;1.Bus是什么❤️❤️❤️ &#x1f32d;2.什么是总线❤️❤️❤️ &#x1f953;3.rabbitmq❤️❤️❤️ &#x1f95e;4.新建模块3366❤️❤️❤️ &#x1f373;5.设计思想 ❤️❤️❤️ &#x1f37f;6.添加消息总线的支持❤️❤️❤️ &#x1f9…...

xshell和xftp

1.xshell和xftp的关系 Xftp和Xshell都是Xmanager Power Suite的组件&#xff0c;它们的功能和用途有所不同。 Xshell是一个用于MS Windows平台的强大的SSH、telnet和rlogin终端仿真软件&#xff0c;它使得用户能轻松和安全地从Windows PC上访问Unix/Linux主机。 Xftp是一个用…...

python for...else用法,一个实例就能让你明白

直接上代码&#xff0c;很简单&#xff0c;不用讲解吧&#xff0c;看不懂的话&#xff0c;就需要补充下基础知识了。 def funct2():for i in range(4):try:assert i>2print("success")breakexcept Exception as e:print(error)continueelse:print(循环不合预期)d…...

windows 设置ip命令bat脚本

您可以使用以下命令创建一个批处理文件&#xff08;.bat&#xff09;来添加IP地址&#xff1a; echo off set ipaddress set subnetmask set gatewaynetsh interface ip set address name"以太网" sourcestatic address%ipaddress% mask%subnetmask% gateway%gatewa…...

Openharmony 对应Android内存查看

众所周知&#xff0c;内存查看是一个很重要的部分&#xff0c;大多数情况&#xff0c;我们都是使用dumpsys的方法对android的内存进行查看&#xff0c;但是对于openharmony而言好像又不太一样了。 Android内存查看 命令行&#xff1a; adb shell dumpsys meminfo <packag…...

R语言【paleobioDB】——pbdb_interval():通过ID选择,返回一个地层年代段的基本信息

Package paleobioDB version 0.7.0 paleobioDB 包在2020年已经停止更新&#xff0c;该包依赖PBDB v1 API。 可以选择在Index of /src/contrib/Archive/paleobioDB (r-project.org)下载安装包后&#xff0c;执行本地安装。 Usage pbdb_interval (id, ...) Arguments 参数【id】…...

spring boot mybatis plus mapper如何自动注册到spring bean容器

##Import(AutoConfiguredMapperScannerRegistrar.class) ##注册MapperScannerConfigurer ##MapperScannerConfigurer.postProcessBeanDefinitionRegistry方法扫描注册mapper ##找到mapper候选者 ##过滤mapper 类 候选者 ##BeanDefinitionHolder注册到spring 容器...

What is `@PathVariable` does?

PathVariable 是SpringMVC中的注解&#xff0c;用于将HTTP请求的URI路径变量映射到Controller方法参数上。 当URL路径中包含占位符&#xff08;由大括号 {} 包围的部分&#xff09;时&#xff0c;可以使用此注解来绑定这些动态部分到方法参数。 使用样例 获取单个路径变量 …...

如何利用小程序介绍公司品牌形象?

企业小程序的建设对于现代企业来说已经成为了一项必不可少的工作。随着移动互联网的快速发展&#xff0c;越来越多的职场人士和创业老板希望通过小程序来提升企业形象&#xff0c;增强与用户的互动&#xff0c;实现更好的商业效果。在这个过程中&#xff0c;使用第三方制作平台…...

[C#]使用sdcb.paddleocr部署v4版本ocr识别模型

【官方框架地址】 https://github.com/sdcb/PaddleSharp 【算法介绍】 PaddleOCR&#xff0c;全称为PaddlePaddle OCR&#xff0c;是PaddlePaddle深度学习平台下的一款强大的光学字符识别工具。它利用深度学习技术&#xff0c;实现了高精度的文字识别&#xff0c;可以帮助用户…...

Echarts图表如何利用formatter自定义tooltip的内容和样式

在展示多数据图表的时候 有的时候需要图例也展示出一些内容来&#xff0c;例如官方这样子&#xff1a;鼠标悬停的时候展示该点数据 但是&#xff0c;官方提供的样式有时不适用所有的开发场景 我的项目需要实现鼠标悬停在某一点的时候&#xff0c;只展示该条线的数据&#xff0…...

Ceph源码分析-s->req_id = store->svc()->zone_utils->unique_id(req->id)

s->req_id store->svc()->zone_utils->unique_id(req->id); 涉及到指针和对象方法的调用。我会逐步为你解释这行代码的含义。 s->req_id ...; s 是一个指针&#xff0c;它指向一个结构或类。req_id 是该结构或类的一个成员变量。这行代码的意思是&#xff…...

Unity中的异步编程【7】——在一个异步方法里播放了animation动画,取消任务时,如何停止动画播放

用一个异步方法来播放一个动画&#xff0c;正常情况是&#xff1a;动画播放结束时&#xff0c;异步方法宣告结束。那如果我提前取消这个异步任务&#xff0c;那在这个异步方法里面&#xff0c;我要怎么停止播放呢&#xff1f;&#xff01; 一、播放animation动画的异步实现 1…...

vue3中ref和reactive联系与区别以及如何选择

vue3中ref和reactive区别与联系 区别 1、ref既可定义基本数据类型&#xff0c;也可以定义引用数据类型&#xff0c;reactive只能定义应用数据类型 2、ref在js中取响应值需要使用 .value&#xff0c;而reactive则直接取用既可 3、ref定义的对象通过.value重新分配新对象时依旧…...

面试宝典之spring框架常见面试题

F1、类的反射机制有啥用&#xff1f; &#xff08;1&#xff09;增加程序的灵活性&#xff0c;可扩展性&#xff0c;动态创建对象。 &#xff08;2&#xff09;框架必备&#xff0c;任何框架的封装都要用反射。&#xff08;框架的灵魂&#xff09; F2、获取Class对象的三种方…...

建筑垃圾处理行业分析:正在被越来越广泛的运用

建筑垃圾处理&#xff0c;是将固体废弃物作为再生资源重新利用的一种方式。建筑垃圾是在对建筑物实施新建、改建、扩建或者是拆除过程中产生的固体废弃物。建筑垃圾一般可分为建设废物、拆除垃圾及装修垃圾。因此建筑垃圾处理行业可以分为建设废物处理、拆除垃圾处理、装修垃圾…...

【DIY summaries on Linux】

DIY Linux summaries 1) difference between ways of creation file and edit files1.1) echoecho talk to yourself touch 1) difference between ways of creation file and edit files 1.1) echo ###) > echo talk to yourself touch...

K8S认证|CKS题库+答案| 11. AppArmor

目录 11. AppArmor 免费获取并激活 CKA_v1.31_模拟系统 题目 开始操作&#xff1a; 1&#xff09;、切换集群 2&#xff09;、切换节点 3&#xff09;、切换到 apparmor 的目录 4&#xff09;、执行 apparmor 策略模块 5&#xff09;、修改 pod 文件 6&#xff09;、…...

黑马Mybatis

Mybatis 表现层&#xff1a;页面展示 业务层&#xff1a;逻辑处理 持久层&#xff1a;持久数据化保存 在这里插入图片描述 Mybatis快速入门 ![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/6501c2109c4442118ceb6014725e48e4.png //logback.xml <?xml ver…...

在鸿蒙HarmonyOS 5中实现抖音风格的点赞功能

下面我将详细介绍如何使用HarmonyOS SDK在HarmonyOS 5中实现类似抖音的点赞功能&#xff0c;包括动画效果、数据同步和交互优化。 1. 基础点赞功能实现 1.1 创建数据模型 // VideoModel.ets export class VideoModel {id: string "";title: string ""…...

java 实现excel文件转pdf | 无水印 | 无限制

文章目录 目录 文章目录 前言 1.项目远程仓库配置 2.pom文件引入相关依赖 3.代码破解 二、Excel转PDF 1.代码实现 2.Aspose.License.xml 授权文件 总结 前言 java处理excel转pdf一直没找到什么好用的免费jar包工具,自己手写的难度,恐怕高级程序员花费一年的事件,也…...

SpringBoot+uniapp 的 Champion 俱乐部微信小程序设计与实现,论文初版实现

摘要 本论文旨在设计并实现基于 SpringBoot 和 uniapp 的 Champion 俱乐部微信小程序&#xff0c;以满足俱乐部线上活动推广、会员管理、社交互动等需求。通过 SpringBoot 搭建后端服务&#xff0c;提供稳定高效的数据处理与业务逻辑支持&#xff1b;利用 uniapp 实现跨平台前…...

关于 WASM:1. WASM 基础原理

一、WASM 简介 1.1 WebAssembly 是什么&#xff1f; WebAssembly&#xff08;WASM&#xff09; 是一种能在现代浏览器中高效运行的二进制指令格式&#xff0c;它不是传统的编程语言&#xff0c;而是一种 低级字节码格式&#xff0c;可由高级语言&#xff08;如 C、C、Rust&am…...

论文笔记——相干体技术在裂缝预测中的应用研究

目录 相关地震知识补充地震数据的认识地震几何属性 相干体算法定义基本原理第一代相干体技术&#xff1a;基于互相关的相干体技术&#xff08;Correlation&#xff09;第二代相干体技术&#xff1a;基于相似的相干体技术&#xff08;Semblance&#xff09;基于多道相似的相干体…...

智能AI电话机器人系统的识别能力现状与发展水平

一、引言 随着人工智能技术的飞速发展&#xff0c;AI电话机器人系统已经从简单的自动应答工具演变为具备复杂交互能力的智能助手。这类系统结合了语音识别、自然语言处理、情感计算和机器学习等多项前沿技术&#xff0c;在客户服务、营销推广、信息查询等领域发挥着越来越重要…...

音视频——I2S 协议详解

I2S 协议详解 I2S (Inter-IC Sound) 协议是一种串行总线协议&#xff0c;专门用于在数字音频设备之间传输数字音频数据。它由飞利浦&#xff08;Philips&#xff09;公司开发&#xff0c;以其简单、高效和广泛的兼容性而闻名。 1. 信号线 I2S 协议通常使用三根或四根信号线&a…...

华为OD机考-机房布局

import java.util.*;public class DemoTest5 {public static void main(String[] args) {Scanner in new Scanner(System.in);// 注意 hasNext 和 hasNextLine 的区别while (in.hasNextLine()) { // 注意 while 处理多个 caseSystem.out.println(solve(in.nextLine()));}}priv…...