Avro 1.8.2 BigDecimal(逻辑类型)的Java代码生成
如何在我的Avro 1.8.2 BigDecimal(逻辑类型)的Java代码生成,java,maven,avro,Java,Maven,Avro,如何在我的Apple类中生成BigDecimal?现在我只有一个ByteBuffer 使用Avro模式(avsc): 使用IDL: @namespace("com.example") protocol AppleProtocol { record Apple { @java-class("java.math.BigDecimal") decimal(9,2) price; } } 使用maven生成方法mvn clean compile和以下maven代码段:
Apple
类中生成BigDecimal
?现在我只有一个ByteBuffer
使用Avro模式(avsc):
使用IDL:
@namespace("com.example")
protocol AppleProtocol {
record Apple {
@java-class("java.math.BigDecimal") decimal(9,2) price;
}
}
使用maven生成方法mvn clean compile和以下maven代码段:
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.8.2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
<goal>idl-protocol</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/main/avro</sourceDirectory>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
如何使此方法请求一个BigDecimal
?
这是使用Avro
1.8.2
为生成的类使用BigDecimal而不是ByteBuffer,set来表示十进制逻辑类型
Avro Maven插件配置参数enableDecimalLogicalType
为true
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.8.2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
<goal>idl-protocol</goal>
</goals>
<configuration>
<enableDecimalLogicalType>true</enableDecimalLogicalType>
</configuration>
</execution>
</executions>
</plugin>
org.apache.avro
avro-maven插件
1.8.2
生成源
模式
idl协议
真的
对于使用BigDecimal而不是ByteBuffer表示十进制逻辑类型的生成类,请设置
Avro Maven插件配置参数enableDecimalLogicalType
为true
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.8.2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
<goal>idl-protocol</goal>
</goals>
<configuration>
<enableDecimalLogicalType>true</enableDecimalLogicalType>
</configuration>
</execution>
</executions>
</plugin>
org.apache.avro
avro-maven插件
1.8.2
生成源
模式
idl协议
真的
谢谢!为什么这不是默认行为?谢谢!为什么这不是默认行为?
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.8.2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
<goal>idl-protocol</goal>
</goals>
<configuration>
<enableDecimalLogicalType>true</enableDecimalLogicalType>
</configuration>
</execution>
</executions>
</plugin>