小编Eri*_*man的帖子

如何将 google.protobuf.Timestamp 与 protoc-jar-maven-plugin 一起使用?

我一直在尝试使用 protobuf 类型google.protobuf.Timestampprotoc-jar-maven-plugin但只得到这些编译时错误:

google/protobuf/timestamp.proto: File not found.
test.proto: Import "google/protobuf/timestamp.proto" was not found or had errors.
test.proto:9:5: "google.protobuf.Timestamp" is not defined.
Run Code Online (Sandbox Code Playgroud)

proto 文件如下所示:

syntax = "proto3";

import "google/protobuf/timestamp.proto";

package test;
option java_package = "test";

message TestTimestamp {
    google.protobuf.Timestamp liveStartDate = 1;
}
Run Code Online (Sandbox Code Playgroud)

而pom文件有如下配置:

<build>
    <plugins>
        <plugin>
            <groupId>com.github.os72</groupId>
            <artifactId>protoc-jar-maven-plugin</artifactId>
            <version>3.6.0.1</version>
            <executions>
                <execution>
                    <id>protoc.main</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <protocVersion>3.6.0</protocVersion>
                        <addSources>main</addSources>
                        <includeDirectories>
                            <include>src/main/protobuf</include>
                        </includeDirectories>
                        <inputDirectories>
                            <include>src/main/protobuf</include>
                        </inputDirectories>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

据我了解,这种类型是 proto3 的一部分,为什么会出现这些错误?

java protocol-buffers maven protoc

5
推荐指数
1
解决办法
1873
查看次数

标签 统计

java ×1

maven ×1

protoc ×1

protocol-buffers ×1