• idea的protobuf使用


    1、安装插件

    2、添加依赖

    <?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.home</groupId>
        <artifactId>CustomFilter</artifactId>
        <version>1.0-SNAPSHOT</version>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <java.version>1.8</java.version>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <grpc.version>1.20.0</grpc.version>
            <protobuf.version>2.5.0</protobuf.version>
        </properties>
    
        <dependencies>
    //hbase客户端 <dependency> <groupId>org.apache.hbase</groupId> <artifactId>hbase-client</artifactId> <version>2.0.4</version> </dependency> <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> <version>${protobuf.version}</version> </dependency> </dependencies> <build> <extensions> <extension> <groupId>kr.motd.maven</groupId> <artifactId>os-maven-plugin</artifactId> <version>1.6.2</version> </extension> </extensions> <plugins> <plugin> <groupId>org.xolstice.maven.plugins</groupId> <artifactId>protobuf-maven-plugin</artifactId> <version>0.6.1</version> <configuration> <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact> <pluginId>grpc-java</pluginId> <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact> <!-- proto文件目录 --> <protoSourceRoot>${project.basedir}/src/main/protobuf</protoSourceRoot> <!-- 生成的Java文件目录 --> <outputDirectory>${project.basedir}/src/main/java/generated</outputDirectory> <!--<outputDirectory>${project.build.directory}/generated-sources/protobuf/java</outputDirectory>--> </configuration> <executions> <execution> <goals> <goal>compile</goal> <goal>compile-custom</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>

    3、maven project里可以看到

    4、使用protobuf:compile后,生成.proto的编译文件.java,然后拷贝java文件到自己需要的包下或者目录下。

     
  • 相关阅读:
    父级和 子集 controller 之间的通讯
    ui-router(三)controller与template
    ui-router详解(二)ngRoute工具区别
    关于MySql全文索引
    Yii提供的Htmler助手checkboxList可自定义Checkbox输出格式
    添加和删除索引以及如何给中间表添加两个主键
    设置数据库及表的默认字符集
    保存数据的时候报类型错误的原因和解决方案
    金融经济
    YII获取刚插入数据的id主键
  • 原文地址:https://www.cnblogs.com/asker009/p/10706411.html
Copyright © 2020-2023  润新知