Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Avro 1.8.2 BigDecimal(逻辑类型)的Java代码生成_Java_Maven_Avro - Fatal编程技术网

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>