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

网站后台登陆验证码不显示阿里巴巴网站建设要多少钱

网站后台登陆验证码不显示,阿里巴巴网站建设要多少钱,方便面网络营销推广方案,一般网站建设需要哪些东西1.什么是protobuf#xff1f; Protobuf#xff08;Protocol Buffers#xff09;是由 Google 开发的一种轻量级、高效的数据交换格式#xff0c;它被用于结构化数据的序列化、反序列化和传输。相比于 XML 和 JSON 等文本格式#xff0c;Protobuf 具有更小的数据体积、更快…1.什么是protobuf ProtobufProtocol Buffers是由 Google 开发的一种轻量级、高效的数据交换格式它被用于结构化数据的序列化、反序列化和传输。相比于 XML 和 JSON 等文本格式Protobuf 具有更小的数据体积、更快的解析速度和更强的可扩展性。 Protobuf 的核心思想是使用协议Protocol来定义数据的结构和编码方式。使用 Protobuf可以先定义数据的结构和各字段的类型、字段等信息然后使用 Protobuf 提供的编译器生成对应的代码用于序列化和反序列化数据。由于 Protobuf 是基于二进制编码的因此可以在数据传输和存储中实现更高效的数据交换同时也可以跨语言使用。 Protobuf 有以下几个优势 更小的数据量Protobuf 的二进制编码通常只有 XML 和 JSON 的 1/3 到 1/10 左右因此在网络传输和存储数据时可以节省带宽和存储空间。更快的序列化和反序列化速度由于 Protobuf 使用二进制格式所以序列化和反序列化速度比 XML 和 JSON 快得多。跨语言Protobuf 支持多种编程语言可以使用不同的编程语言来编写客户端和服务端。这种跨语言的特性使得 Protobuf 受到很多开发者的欢迎JSON 也是如此。易于维护可扩展Protobuf 使用 .proto 文件定义数据模型和数据格式这种文件比 XML 和 JSON 更容易阅读和维护且可以在不破坏原有协议的基础上轻松添加或删除字段实现版本升级和兼容性。 2.代码工程 实验目标 rest api实现基于Protobuf 协议通信 pom.xml ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion3.2.1/version/parentmodelVersion4.0.0/modelVersionartifactIdprotobuf/artifactIdpropertiesmaven.compiler.source17/maven.compiler.sourcemaven.compiler.target17/maven.compiler.target/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-autoconfigure/artifactId/dependencydependencygroupIdcom.google.protobuf/groupIdartifactIdprotobuf-java/artifactIdversion3.19.2/version/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-test/artifactIdscopetest/scope/dependency/dependencies buildextensionsextensiongroupIdkr.motd.maven/groupIdartifactIdos-maven-plugin/artifactIdversion1.6.1/version/extension/extensionspluginsplugingroupIdorg.xolstice.maven.plugins/groupIdartifactIdprotobuf-maven-plugin/artifactIdversion0.6.1/versionconfigurationprotoSourceRoot${basedir}/src/main/resources/protoSourceRootprotocArtifactcom.google.protobuf:protoc:3.19.1:exe:${os.detected.classifier}/protocArtifactpluginArtifactio.grpc:protoc-gen-grpc-java:1.43.1:exe:${os.detected.classifier}/pluginArtifactoutputDirectorysrc/main/java/outputDirectoryclearOutputDirectoryfalse/clearOutputDirectorypluginIdgrpc-java/pluginId/configurationexecutionsexecutiongoalsgoalcompile/goalgoalcompile-custom/goal/goals/execution/executions/pluginplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins /build/project controller package com.et.protobuf.controller;import com.et.protobuf.PhoneNumJson; import com.et.protobuf.ProtobufMessage; import com.et.protobuf.StudentJson; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;RestController public class HelloWorldController {RequestMapping(/json/{id})public StudentJson showHelloWorld(PathVariable Integer id){StudentJson studentJson new StudentJson();studentJson.setId(id);studentJson.setFirstName(maxsm);studentJson.setLastName(sdfsdfsdfsdfsdfsdsdfsdfsdfsdfsdfsdfsdfsdf);studentJson.setEmail(1224sdfsfsdf344552163.com);PhoneNumJson phoneNumJson new PhoneNumJson();phoneNumJson.setNumber(12345sdfsdfsd6566666);phoneNumJson.setType(1);ListPhoneNumJson list new ArrayList();list.add(phoneNumJson);studentJson.setPhoneNumList(list);return studentJson;}RequestMapping(/protobuf/{id})ProtobufMessage.Student protobuf(PathVariable Integer id) {return ProtobufMessage.Student.newBuilder().setId(id).setFirstName(maxsm).setLastName(sdfsdfsdfsdfsdfsdsdfsdfsdfsdfsdfsdfsdfsdf).setEmail(1224sdfsfsdf344552163.com).addPhone(ProtobufMessage.Student.PhoneNumber.newBuilder().setNumber(12345sdfsdfsd6566666).setType(ProtobufMessage.Student.PhoneType.MOBILE).build()).build();}} entity package com.et.protobuf;import java.util.List;/*** author liuhaihua* version 1.0* ClassName StudentJson* Description todo* date 2024/08/05/ 16:32*/ public class StudentJson {private int id;private String firstName;private String lastName;private String email;private ListPhoneNumJson phoneNumList;public int getId() {return id;}public void setId(int id) {this.id id;}public String getFirstName() {return firstName;}public void setFirstName(String firstName) {this.firstName firstName;}public String getLastName() {return lastName;}public void setLastName(String lastName) {this.lastName lastName;}public String getEmail() {return email;}public void setEmail(String email) {this.email email;}public ListPhoneNumJson getPhoneNumList() {return phoneNumList;}public void setPhoneNumList(ListPhoneNumJson phoneNumList) {this.phoneNumList phoneNumList;} } package com.et.protobuf;/*** author liuhaihua* version 1.0* ClassName PhoneNum* Description todo* date 2024/08/05/ 16:35*/public class PhoneNumJson {private int type;private String number;public int getType() {return type;}public void setType(int type) {this.type type;}public String getNumber() {return number;}public void setNumber(String number) {this.number number;} } mxsm.proto 使用 Protobuf 的语言定义文件.proto可以定义要传输的信息的数据结构可以包括各个字段的名称、类型等信息。同时也可以相互嵌套组合构造出更加复杂的消息结构。 syntax proto3; package mxsm; option java_package com.et.protobuf; option java_outer_classname ProtobufMessage;message Course {int32 id 1;string course_name 2;repeated Student student 3; } message Student {int32 id 1;string first_name 2;string last_name 3;string email 4;repeated PhoneNumber phone 5;message PhoneNumber {string number 1;PhoneType type 2;}enum PhoneType {MOBILE 0;LANDLINE 1;} } 头部全局定义 syntax proto3; 指定 Protobuf 版本为版本 3最新版本package com.wdbyte.protobuf; 指定 Protobuf 包名防止有相同类名的 message 定义这个包名是生成的类中所用到的一些信息的前缀并非类所在包。option java_multiple_files true; 是否生成多个文件。若 false则只会生成一个类其他类以内部类形式提供。option java_package  生成的类所在包。option java_outer_classname 生成的类名若无自动使用文件名进行驼峰转换来为类命名。 消息结构具体定义 message Person 定一个了一个 Person 类。 Person 类中的字段被 optional 修饰被 optional 修饰说明字段可以不赋值。 修饰符 optional 表示可选字段可以不赋值。修饰符 repeated 表示数据重复多个如数组如 List。修饰符 required 表示必要字段必须给值否则会报错 RuntimeException但是在 Protobuf 版本 3 中被移除。即使在版本 2 中也应该慎用因为一旦定义很难更改。 字段类型定义 修饰符后面紧跟的是字段类型如 int32 、string。常用的类型如下 int32、int64、uint32、uint64整数类型包括有符号和无符号类型。float、double浮点数类型。bool布尔类型只有两个值true 和 false。string字符串类型。bytes二进制数据类型。enum枚举类型枚举值可以是整数或字符串。message消息类型可以嵌套其他消息类型类似于结构体。 字段后面的 12 是作为序列化后的二进制编码中的字段的对应标签因为 Protobuf 消息在序列化后是不包含字段信息的只有对应的字段序号所以节省了空间。也因此1-15 比 16 会少一个字节所以尽量使用 1-15 来指定常用字段。且一旦定义不要随意更改否则可能会对不上序列化信息。 config package com.et.protobuf.config;import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter; import org.springframework.web.client.RestTemplate;import java.util.Arrays;Configuration public class Config {BeanRestTemplate restTemplate(ProtobufHttpMessageConverter hmc) {return new RestTemplate(Arrays.asList(hmc));}BeanProtobufHttpMessageConverter protobufHttpMessageConverter() {return new ProtobufHttpMessageConverter();} } 以上只是一些关键代码所有代码请参见下面代码仓库 代码仓库 GitHub - Harries/springboot-demo: a simple springboot demo with some components for example: redis,solr,rockmq and so on.(Protobuf 3.测试 启动Spring Boot应用 编写测试类 package com.et.protobuf;import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter; import org.springframework.web.client.RestTemplate;import java.util.ArrayList; import java.util.List;SpringBootTest(classes DemoApplication.class) public class ApplicationTest {// Other declarationsprivate static final String COURSE1_URL http://localhost:8088/protobuf/1;Autowiredprivate RestTemplate restTemplate ;Testpublic void whenUsingRestTemplate_thenSucceed() {ResponseEntityProtobufMessage.Student student restTemplate.getForEntity(COURSE1_URL, ProtobufMessage.Student.class);System.out.println(student.toString());} } 结果如下 200 OK OK,id: 1 first_name: maxsm last_name: sdfsdfsdfsdfsdfsdsdfsdfsdfsdfsdfsdfsdfsdf email: 1224sdfsfsdf344552163.com phone {number: 12345sdfsdfsd6566666 } ,[X-Protobuf-Schema:mxsm.proto, X-Protobuf-Message:mxsm.Student, Content-Type:application/x-protobuf;charsetUTF-8, Transfer-Encoding:chunked, Date:Mon, 05 Aug 2024 09:10:55 GMT, Keep-Alive:timeout60, Connection:keep-alive] Json和protobuf性能比较 单个线程循环1分钟 测试结果发现json性能甚至优于protobuf并不符合预期结果是我哪一步整错了吗有大神知道怎么回事吗 4.引用 Overview | Protocol Buffers Documentation
http://www.hkea.cn/news/14379575/

相关文章:

  • mifa网站开发费用黄陂区建设局网站
  • 网站建设 sql 模版公司网站设计基础任务书
  • 北京网站怎么建设原创网站开发流程
  • 网站建设需要学些什么郑州可以做网站的公司
  • 网站外链可以在哪些平台上做外链网站建设公司广告语 宣传语
  • 传统的网站开发模式和mvcphpcms如何发布网站
  • 怎么做一元抽奖网站汉阳网站建设
  • 网站开发和后台维护网络舆情是什么意思
  • 网站的特点成立公司股权怎么分配
  • 一人开公司做网站创业wordpress 大气主题
  • 公司网站建设费怎么写分录湛江网站建设技术托管
  • 内蒙古网站制作公司怎么做网站发货
  • wordpress最新的编辑器windows优化大师是官方的吗
  • 网站是生成静态好还是动态好网站后台的目录在哪
  • 企业建站wordpress做淘宝客必须要有网站吗
  • 网站动态加速广州思盾互动网站建设公司
  • 专门做家居的网站网站建设的课程
  • 有做学历在网站能查的到的windows 2003 iis 多网站
  • 抚州营销型网站建设展示型网站首页设计解析
  • 摄影网站网址大全专业公司网站建设服务公司
  • 河南省建设监理协会官方网站电商代运营一般收多少服务费
  • 重点培育学科建设网站argo wordpress 汉化
  • 定西市建设厅官方网站企业网站托管多少钱
  • 网站平台都有哪些金属材料网站建设
  • 自己做网站卖东西怎么样wordpress 标签 超链接
  • 网站建设存在的具体问题利为汇wordpress教程
  • 网站建设领域的基本五大策略要学会网易 自助网站建设
  • 青岛做公司网站的多吗台州网页设计公司
  • 深圳网站建设 案例网站外链建设书籍
  • wordpress站点标题图片wordpress搬家失败