Maven引入avro依赖及插件

一、在pom.xml文件的依赖中,添加avro依赖,当前最新版本1.10.1

<dependency>
        <groupId>org.apache.avro</groupId>
        <artifactId>avro</artifactId>
        <version>1.10.1</version>
</dependency>

二、在build plugins添加avro-maven-plugin插件


            <plugin>
                <groupId>org.apache.avro</groupId>
                <artifactId>avro-maven-plugin</artifactId>
                <version>1.10.1</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>schema</goal>
                            <goal>protocol</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>

三、执行命令mvn clean install即可在源代码中生成序列化代码

发表评论

邮箱地址不会被公开。 必填项已用*标注


− 三 = 3