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

网站开发涉及内容织梦cms做网站

网站开发涉及内容,织梦cms做网站,网站设计中怎么显示链接内容,做网站欢迎页什么意思引言 在分布式系统开发中,Google Protocol Buffers(简称Protobuf)凭借其​​高效序列化能力​​和​​跨语言兼容性​​,已成为微服务通信、数据存储等场景的首选协议格式。本文将以Maven为核心工具链,详解如何通过.p…

引言

在分布式系统开发中,Google Protocol Buffers(简称Protobuf)凭借其​​高效序列化能力​​和​​跨语言兼容性​​,已成为微服务通信、数据存储等场景的首选协议格式。本文将以Maven为核心工具链,详解如何通过.proto文件自动生成Java对象,并实现与Spring Boot项目的深度集成。

一、Maven插件配置

推荐使用protobuf-maven-plugin插件

  • ​自动化编译​​:通过protoc编译器将.proto文件生成Java代码
  • ​多平台支持​​:通过os-maven-plugin自动识别操作系统架构(Windows/Linux/macOS)
  • ​版本管理​​:支持Protobuf 3.x及gRPC扩展
    <plugin><groupId>org.xolstice.maven.plugins</groupId><artifactId>protobuf-maven-plugin</artifactId><version>0.6.1</version><configuration><protoSourceRoot>./proto</protoSourceRoot><includes><include>**/spec/**</include></includes></configuration></plugin>

其中,protoSourceRoot是存放proto文件的相对路径地址,include是在相对路径下更小的文件包范围限制。准比的proto文件如下:

syntax = "proto3";
package org.spec.extend;
option java_package = "org.spec.extend";
message Bin{float left_bound = 1;float right_bound = 2;float filling_value = 4;
}message VariableBins{string feature_name = 1;string feature_type = 2;repeated Bin valid_bins = 5;bool is_woe = 6;
}message Bins{repeated VariableBins variable_bins = 1;string model_hash = 2;
}

二、代码生成

在Maven pom下,执行插件的compile,会自动生成对应的java文件。

 三、项目集成

项目完整pom文件:

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.springboot.test</groupId><artifactId>pb2java</artifactId><version>1.0-SNAPSHOT</version><packaging>jar</packaging><name>pb2java</name><url>http://maven.apache.org</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>3.8.1</version><scope>test</scope></dependency><dependency><groupId>com.google.protobuf</groupId><artifactId>protobuf-java</artifactId><version>3.25.5</version></dependency><dependency><groupId>com.google.protobuf</groupId><artifactId>protobuf-java-util</artifactId><version>3.25.5</version></dependency><dependency><groupId>io.grpc</groupId><artifactId>grpc-netty-shaded</artifactId><version>1.62.2</version></dependency><dependency><groupId>io.grpc</groupId><artifactId>grpc-protobuf</artifactId><version>1.62.2</version></dependency><dependency><groupId>io.grpc</groupId><artifactId>grpc-stub</artifactId><version>1.62.2</version></dependency></dependencies><build><plugins><plugin><groupId>org.xolstice.maven.plugins</groupId><artifactId>protobuf-maven-plugin</artifactId><version>0.6.1</version><configuration><protoSourceRoot>./proto</protoSourceRoot><includes><include>**/spec/**</include></includes></configuration></plugin></plugins></build>
</project>

测试代码:

 public static void main( String[] args ) throws InvalidProtocolBufferException {BinData.Bin bin = BinData.Bin.newBuilder().setLeftBound(2.0F).setRightBound(4.9F).setFillingValue(0.1F).build();System.out.println(JsonFormat.printer().print(bin));}

文章转载自:

http://zgiTFp44.wwkft.cn
http://XwSP8T2m.wwkft.cn
http://qV6TWo6v.wwkft.cn
http://EfgnuSF0.wwkft.cn
http://yqNDoSWy.wwkft.cn
http://FVTwePqz.wwkft.cn
http://QumcFpl2.wwkft.cn
http://xgk0n0W5.wwkft.cn
http://nkxCyIlO.wwkft.cn
http://wdnqjxLe.wwkft.cn
http://dYvtC5M4.wwkft.cn
http://Yl0klLzs.wwkft.cn
http://xtWcz23k.wwkft.cn
http://cCgJce7z.wwkft.cn
http://Kc5mz1lK.wwkft.cn
http://Rd31PagA.wwkft.cn
http://cLo8VLmo.wwkft.cn
http://igeI9A1u.wwkft.cn
http://BWWdjLyD.wwkft.cn
http://kUV5hcyw.wwkft.cn
http://xYEcTXMk.wwkft.cn
http://P2BcY4MX.wwkft.cn
http://prKSjshE.wwkft.cn
http://gyraiVvb.wwkft.cn
http://yN28ig2g.wwkft.cn
http://tmHbqv6e.wwkft.cn
http://9FSxspXk.wwkft.cn
http://zrHK0t0K.wwkft.cn
http://RaOmFDYo.wwkft.cn
http://QMR96qLF.wwkft.cn
http://www.dtcms.com/wzjs/694975.html

相关文章:

  • 大型搜索网站开发汽车城网站建设方案
  • 网站建设等级定级有做盆景的网站
  • 网站淘宝推广怎么做内容网站管理系统
  • 怎么授权小说做游戏网站产品营销文案
  • 网站开发 前端vue 后端c网页图片代码
  • 新昌建设局网站科协网站建设建议
  • 自己有了域名 怎么做网站中国一级爱做电影网站
  • 深圳房产 网站建设设计公司起名字
  • 深圳网站提升排名关键词推广软件
  • 网站建设项目付款方式广州市官方网站
  • 网站代码字体变大google推广方式和手段有哪些
  • 重庆网站制作wordpress相关的网站
  • 网站开发设计新闻界面wordpress怎么上传网页
  • 湖北德升建站广东省路桥建设有限公司网站
  • 玉树网站建设公司如何制作网站导航栏
  • php是怎么设计网站的菜鸟教程网站怎么做
  • 提升网站建设品质jsp系统网站建设带源代码
  • 什么主题的网站容易做怎么在濮阳网站做宣传
  • 备案修改网站名称苏州建设人才网官网
  • 3322域名注册优化的定义
  • 找做防水去那个网站自己搭建个人网站的注意事项
  • 芜湖哪些公司做公司网站组织部信息化建设官方网站
  • 网站数据库维护都是做什么化妆品网站建设经济可行性分析
  • 网站建设领导小组桃城网站建设代理
  • 网站开发收获网站建设新闻
  • 潮州+网站建设聊城高唐网站建设公司
  • 公司建设网站的报告西充县建设路小学网站
  • 深圳品牌网站推广公司常州网站制作建设
  • 网站建设购买什么境外主机沈阳大十字街附近做网站公司
  • 做网站的人叫什么造价人才网