[英]Using string instead of java.lang.charsequence
(apache avro 1.8.2, avro-maven-plugin 1.8.2) (apache avro 1.8.2, avro-maven-plugin 1.8.2)
I'm having problem with avro:schema.我在使用 avro:schema 时遇到问题。
I declared a field like under below我在下面声明了一个字段
{
"name": "type",
"type": {
"type": "string",
"avro.java.string": "java.lang.String"
}
},
but avro:schema converts like但是 avro:schema 转换成
@Deprecated public java.lang.CharSequence type;
...
public OptionDetail(..., java.lang.CharSequence type, ...) {
...
this.type = type;
...
}
What I tried:我尝试了什么:
"avro.java.string": "java.lang.String"
<stringType>String</stringType>
Both of above doesn't work properly.以上两个都不能正常工作。 Please let me know what should I try more.请让我知道我应该多尝试什么。 Thanks.谢谢。
Have you tried upgrading to Avro version 1.10.0
?您是否尝试过升级到 Avro 版本1.10.0
? I don't see the issue in this version.我在这个版本中没有看到问题。 Setting the stringType
field in the pom fixed it for me, so I expect it's just a version problem.在 pom 中设置stringType
字段为我修复了它,所以我认为这只是一个版本问题。
If you want all you string fields be instances of java.lang.String
then you only have to configure the compiler:如果您希望所有字符串字段都是java.lang.String
的实例,那么您只需配置编译器:
java -jar /path/to/avro-tools-1.7.7.jar compile -string schema
or if you are using the Maven plugin或者如果您使用的是 Maven 插件
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.7.7</version>
<configuration>
<stringType>String</stringType>
</configuration>
[...]
</plugin>
More details: https://stackoverflow.com/a/25315412/2945616更多详情: https://stackoverflow.com/a/25315412/2945616
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.