protobuf - java

maven

打包插件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
<goal>test-compile</goal>
<goal>test-compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>

IDEA

引用飘红

把 proto 所在文件夹标记为 source root。

对比

StringValue & string

类似的还有 int32 & Int32Value 等。

StringValuestring 相比:

  • StringValue 可以为 null,在部分语言中,string 类型数据不能为 null,那么对于 string 类型,无法区分 "" 是代表 null 还是空字符串
  • gRPC 调用过程的的参数和返回值不能为基本类型,也就是不能为 string、int32 这种