编译protoc后,Java代码有很多错误

时间:2015-04-29 07:31:54

标签: java protocol-buffers

为什么protoc生成的类会产生以下编译错误?

Description Resource Path Location Type Cannot override the final method
from GeneratedMessage AddressBookProtos.java
/monitor/src/main/resources/com/example/tutorial line 102 Java Problem
Cannot override the final method from GeneratedMessage
AddressBookProtos.java /monitor/src/main/resources/com/example/tutorial
line 339 Java Problem Cannot override the final method from
GeneratedMessage AddressBookProtos.java

和我的pom.xml ::

<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.6</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.6</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.13</version>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>2.4.1</version>
        </dependency>
    </dependencies>

1 个答案:

答案 0 :(得分:0)

我不认为你的pom文件在这里是相关的。错误消息非常明确: 无法覆盖最终方法 。单词 final 用于避免覆盖的方法,因此删除final应该有帮助,否则包含代码。