简体   繁体   English

如何在IntelliJ中加载avro架构?

[英]How do I load a avro schema in IntelliJ?

I cloned a project from github and now have it open as a project in IntelliJ. 我从github克隆了一个项目,现在把它打开作为IntelliJ中的一个项目。 The project is written in Scala. 该项目是用Scala编写的。

The project depends on some objects defined in an avro schema that is in another project on github. 该项目依赖于github上另一个项目中的avro架构中定义的一些对象。 The avro schema is a single *.avdl file. avro架构是单个* .avdl文件。

How do I load the avro *.advl schema / file in my project in IntelliJ? 如何在IntelliJ中的项目中加载avro * .advl架构/文件?

So that the object types defined in the avro schema are known in the rest of the project. 因此,avro架构中定义的对象类型在项目的其余部分中是已知的。

Does IntelliJ recognize avro *.advl files? IntelliJ是否识别avro * .advl文件? Do I need to generate Scala/Java classes somehow from the avro advl file? 我是否需要以某种方式从avro advl文件生成Scala / Java类? And then load these classes? 然后加载这些类?

Have you tried the Avro support plugin? 你试过Avro支持插件吗? https://plugins.jetbrains.com/plugin/7971?pr=idea https://plugins.jetbrains.com/plugin/7971?pr=idea

What I ended up doing is: 我最终做的是:

Download avro tools: https://github.com/miguno/avro-cli-examples/blob/master/README.md 下载avro工具: https//github.com/miguno/avro-cli-examples/blob/master/README.md

Use the following tools from the jar 使用jar中的以下工具

idl2schemata  Extract JSON schemata of the types from an Avro IDL file
compile  Generates Java code for the given schema

The resulting set of java classes I put under the correct package in my code. 我在我的代码中放在正确的包下的生成的java类集。

This at least made the type checker happy in IntelliJ. 至少这使得类型检查器在IntelliJ中很开心。 Did not run the code yet. 还没有运行代码。

I recently started an Avro project and was annoyed at having to use avro-tools.jar, so I made an IntelliJ plugin - https://plugins.jetbrains.com/plugin/12281-avro-viewer . 我最近开始了一个Avro项目并且因为不得不使用avro-tools.jar而烦恼,所以我制作了一个IntelliJ插件 - https://plugins.jetbrains.com/plugin/12281-avro-viewer Drag-and-drop Avro files and they're displayed in plain text. 拖放Avro文件,它们以纯文本显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM