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

什么服装网站做一件代发it运维主要做什么

什么服装网站做一件代发,it运维主要做什么,nas wordpress将好的文章转载,创建自己的个人网站grpc接口调用 准备依赖包clientserver 参考博客#xff1a; Grpc项目集成到java方式调用实践 gRpc入门和springboot整合 java 中使用grpc java调用grpc服务 准备 因为需要生成代码#xff0c;所以必备插件 安装后重启 依赖包 ?xml version1.0 encoding Grpc项目集成到java方式调用实践 gRpc入门和springboot整合 java 中使用grpc java调用grpc服务 准备 因为需要生成代码所以必备插件 安装后重启 依赖包 ?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.xsdmodelVersion4.0.0/modelVersiongroupIdorg.example/groupIdartifactIdmistra/artifactIdversion1.0-SNAPSHOT/versionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.7.10/versionrelativePath//parentpropertiesmaven.compiler.source11/maven.compiler.sourcemaven.compiler.target11/maven.compiler.targetprotoc.version3.25.2/protoc.versiongrpc.version1.61.1/grpc.versionproject.build.sourceEncodingUTF-8/project.build.sourceEncoding/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdio.grpc/groupIdartifactIdgrpc-stub/artifactIdversion${grpc.version}/version/dependencydependencygroupIdio.grpc/groupIdartifactIdgrpc-core/artifactIdversion${grpc.version}/version/dependencydependencygroupIdcom.google.protobuf/groupIdartifactIdprotobuf-java/artifactIdversion3.25.2/version !-- 或者与你的 protoc.version 相匹配的版本 --/dependencydependencygroupIdio.grpc/groupIdartifactIdgrpc-netty/artifactIdversion${grpc.version}/version/dependencydependency!-- necessary for Java 9 --groupIdorg.apache.tomcat/groupIdartifactIdannotations-api/artifactIdversion6.0.53/version/dependency/dependenciesbuildextensionsextensiongroupIdkr.motd.maven/groupIdartifactIdos-maven-plugin/artifactIdversion1.6.2/version/extension/extensionspluginsplugingroupIdorg.xolstice.maven.plugins/groupIdartifactIdprotobuf-maven-plugin/artifactIdversion0.6.1/versionconfigurationprotocArtifactcom.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}/protocArtifactpluginIdgrpc-java/pluginIdpluginArtifactio.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}/pluginArtifact/configurationexecutionsexecutiongoalsgoalcompile/goalgoalcompile-custom/goal/goals/execution/executions/pluginplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build /project 在resource同级目录下创建一个包包下创建proto文件 proto文件 syntax proto3;package mistra; //生成的java代码包名 option java_package org.example.mistra; //创建的javaBean的文件名 option java_outer_classname MistraProto; //option java_generic_services true; option java_multiple_files true;//请求 message MistraRequest {string id 1;int64 timestamp 2;string message 3; }//响应 message MistraResponse {string message 1; } //声明一个服务名称 service MistraService {rpc SendMessage(MistraRequest) returns (MistraResponse) {} } 然后使用maven打包在target目录下生成代码复制到自己的目录下。 生成代码 复制到自己目录下再创建一个client和server结构如下 client package com.test.grpc.mistra.generate.client;import com.test.grpc.mistra.generate.MistraRequest; import com.test.grpc.mistra.generate.MistraResponse; import com.test.grpc.mistra.generate.MistraServiceGrpc; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder;import java.util.concurrent.TimeUnit;/*** author清梦* site www.xiaomage.com* company xxx公司* create 2024-06-04 21:59*/ public class MistraClient {private final ManagedChannel channel;private final MistraServiceGrpc.MistraServiceBlockingStub blockingStub;public MistraClient(String host, int port) {channel ManagedChannelBuilder.forAddress(host, port).usePlaintext().build();blockingStub MistraServiceGrpc.newBlockingStub(channel);}public void shutdown() throws InterruptedException {channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);}public void greet(String name) {MistraRequest request MistraRequest.newBuilder().setId(name).build();MistraResponse response blockingStub.sendMessage(request);System.out.println(response.getMessage());}public static void main(String[] args) throws InterruptedException {MistraClient client new MistraClient(127.0.0.1, 8001);System.out.println(-------------------客户端开始访问请求-------------------);for (int i 0; i 10; i) {client.greet(你若想生存绝处也能缝生: i);}} } server package com.test.grpc.mistra.generate.server;import com.test.grpc.mistra.generate.MistraRequest; import com.test.grpc.mistra.generate.MistraResponse; import com.test.grpc.mistra.generate.MistraServiceGrpc; import io.grpc.BindableService; import io.grpc.Server; import io.grpc.ServerBuilder; import io.grpc.stub.StreamObserver;import java.io.IOException;/*** author清梦* site www.xiaomage.com* company xxx公司* create 2024-06-04 21:59*/ public class MistraServer {private int port;private Server server;private void start() throws IOException{server ServerBuilder.forPort(port).addService((BindableService) new MistraSendMessage()).build().start();System.out.println(-------------------服务端服务已开启等待客户端访问------------------);Runtime.getRuntime().addShutdownHook(new Thread(){Overridepublic void run() {System.out.println(*** shutting down gRPC server since JVM is shutting down);MistraServer.this.stop();System.err.println(*** server shut down);}});}private void stop() {if (server ! null) {server.shutdown();}}private void blockUntilShutdown() throws InterruptedException {if (server ! null) {server.awaitTermination();}}public static void main(String[] args) throws IOException, InterruptedException {final MistraServer server new MistraServer();//启动服务server.start();//服务一直在线不关闭server.blockUntilShutdown();}private class MistraSendMessage extends MistraServiceGrpc.MistraServiceImplBase {Overridepublic void sendMessage(MistraRequest request, StreamObserverMistraResponse responseObserver) {//业务实现代码System.out.println(server: request.getId());MistraResponse response MistraResponse.newBuilder().setMessage(响应信息 request.getMessage()).build();responseObserver.onNext(response);responseObserver.onCompleted();}}}
http://www.w-s-a.com/news/787597/

相关文章:

  • 如何用云服务器建设网站微网站免费开发平台
  • 官网的网站设计公司做网站需要准备哪些东西
  • 程序员和做网站那个好找工作wordpress二维码 插件
  • 湖南城市建设技术学院官方网站青海省建设局网站
  • 响应式网站有什么区别百度网站官网
  • 金华企业自助建站系统长沙建站公司模板
  • 云主机 做网站友情链接网站
  • 定制型网站设计天津网站模板建站
  • 为什么公司网站打开很慢wordpress汉化插件
  • 用dw做教学网站做网站用什么配置笔记本
  • 秦皇岛网站制作服务无网站无产品链接如何做SOHO
  • 国际婚恋网站做翻译合法吗南宁网络推广有限公司
  • 济南做网站公司排名销售市场规划方案
  • 营销型网站定制珠海建站网站
  • 企业网站代码wordpress页面重定向循环
  • 厦门网站建设哪家便宜用wordpress做企业网站
  • 网站备案有幕布python 做网站速度
  • 旅游网站模板psd网站后台维护主要做什么
  • 晋江做任务的网站网站如何设置关键词
  • 呼伦贝尔网站建设呼伦贝尔ps网页设计心得体会
  • 字母logo设计网站动画设计方案及内容
  • 怎样做网站建设方案wordpress 附件预览
  • 网站内容编辑wordpress cron原理
  • 户外商品网站制作建筑网络图片
  • 注册了网站怎么建设做网站是学什么专业
  • 济南建设网站哪里好网站色哦优化8888
  • 什么网站做简历最好外贸公司网站大全
  • 衡水网站托管企业二级网站怎么做
  • 丹阳网站建设公司旅游类网站开发开题报告范文
  • 地方门户网站建设苏州网站优化建设