java - 如何将Apach AVRO IDL编译成java?

标签 java python avro

我有一个 Apache AVRO IDL,它定义了我想在 Java 客户端和用 Python 编写的服务器之间使用的协议(protocol)。

@namespace("myproto.proto")

protocol myproto 
{

  enum Status
  {
    STATUS_OK,
    STATUS_ERROR
  }

  record GameList
  {
    array<string> games;
  }

  void somefunc(int arg);
}

对于Python,我使用这个:

AVROTOOLS=$(TOOLS_PATH)/avro-tools-1.7.4.jar
java -jar $(AVROTOOLS) idl fairunfair.avdl fairunfair.avpr

如何将 IDL 编译为 Java?如果可能的话,不使用 Maven。

最佳答案

您可以使用 avro-tools 从 IDL 生成 JSON 架构:

java -jar avro-tools-1.7.4.jar idl /path/to/idl

然后像往常一样将模式编译为 Java:

java -jar avro-tools-1.7.4.jar compile schema /path/to/schema .

我认为没有任何方法可以直接从 IDL 编译为 Java。 avro-tools 帮助菜单没有显示这样的选项。

关于java - 如何将Apach AVRO IDL编译成java?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19820225/

相关文章:

Java 单元测试 - 常量字段与 setUp()

c# - Avro.AvroException : Array does not implement non-generic IList in field 异常

java - Avro 架构 Java 深度复制问题与字段顺序

向服务器发送 avro/bytes POST 请求的 java 示例

java - 为什么 Eclipse 报告从 float 到 double 的转换错误

java - 将多个 java arraylist 合并到一个 json 对象中

java - 将@Produces 与@Qualifier 一起使用

python - 在两列python数据框之间的范围内搜索特定值

python - SWIG 中的垃圾收集和自定义 getter

python - LabelPropagation - 如何避免被零除?