【问题标题】:Maven : Failed to execute Avro goal (Error compiling protocol file)Maven:无法执行 Avro 目标(编译协议文件时出错)
【发布时间】:2022-09-28 18:12:36
【问题描述】:

我有一些使用自定义逻辑类型的 Avro 文件。当我尝试使用 mvn clean install 构建我的项目以自动生成我的 Java 类时。我已经尝试过以下实现 Street 类型的示例 (https://github.com/markush81/avro-examples)。我收到以下错误:

Failed to execute goal org.apache.avro:avro-maven-plugin:1.11.0:schema (schemas) on project atlas_v: Error compiling protocol file to project\\src\\main\\java

下面是我的pom.xml:

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<project xmlns=\"http://maven.apache.org/POM/4.0.0\"
         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.vadis</groupId>
    <artifactId>atlas_v</artifactId>
    <version>1.2</version>


    <properties>
        <java.version>1.8</java.version>
        <atlas.version>2.0.0</atlas.version>
        <avro.version>1.11.0</avro.version>
        <spark.version>3.0.1</spark.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <distributionManagement>
        <repository>
            <id>gitlab-atlas</id>
            <!--suppress UnresolvedMavenProperty -->
            <url>${CI_API_V4_URL}/projects/${env.CI_PROJECT_ID}/packages/maven</url>
        </repository>
        <snapshotRepository>
            <id>gitlab-atlas</id>
            <!--suppress UnresolvedMavenProperty -->
            <url>${CI_API_V4_URL}/projects/${env.CI_PROJECT_ID}/packages/maven</url>
        </snapshotRepository>
    </distributionManagement>

    <dependencies>
        .......
        <dependency>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro-maven-plugin</artifactId>
            <version>${avro.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-common</artifactId>
            <version>${atlas.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-client-v2</artifactId>
            <version>${atlas.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-client-v1</artifactId>
            <version>${atlas.version}</version>
        </dependency>
     .... dependencies
    </dependencies>

    <build>
        <plugins>
            .... others plugins
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


            <plugin>

                <groupId>org.apache.avro</groupId>
                <artifactId>avro-maven-plugin</artifactId>
                <version>${avro.version}</version>
                <executions>
                    <execution>
                        <id>schemas</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>schema</goal>
                            <goal>protocol</goal>
                            <goal>idl-protocol</goal>
                        </goals>
                    </execution>

                </executions>
                <configuration>
                    <sourceDirectory>${project.basedir}/src/main/resources/</sourceDirectory>
                    <outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
                    <enableDecimalLogicalType>true</enableDecimalLogicalType>
                    <customConversions>
                        <customConversion>com.vadis.atlas_v.model.avro.utils.StreetConversion</customConversion>
                    </customConversions>
                    <customLogicalTypeFactories>                       
 
<customLogicalTypeFactory>com.vadis.atlas_v.model.avro.utils.StreetLogicalTypeFactory</customLogicalTypeFactory>
                    </customLogicalTypeFactories>
                </configuration>

            </plugin>
        </plugins>
    </build>

</project>

    标签: java maven avro


    【解决方案1】:

    我有这个完全相同的错误。我的问题是 Avro 正在编译的 .java 源文件已经存在并且归另一个用户所有。

    【讨论】:

      猜你喜欢
      • 2020-09-06
      • 2018-11-13
      • 1970-01-01
      • 2019-08-16
      • 2016-07-16
      • 2021-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多