Java 如何将google.protobuf.Timestamp与ProtocJarMaven插件一起使用?

Java 如何将google.protobuf.Timestamp与ProtocJarMaven插件一起使用?,java,maven,protocol-buffers,protoc,Java,Maven,Protocol Buffers,Protoc,我一直试图将protobuf类型google.protobuf.Timestamp与protocjarmaven插件一起使用,但只得到以下编译时错误: 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"

我一直试图将protobuf类型
google.protobuf.Timestamp
protocjarmaven插件一起使用,但只得到以下编译时错误:

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.
原型文件如下所示:

syntax = "proto3";

import "google/protobuf/timestamp.proto";

package test;
option java_package = "test";

message TestTimestamp {
    google.protobuf.Timestamp liveStartDate = 1;
}
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>

com.github.os72
ProtocJarMaven插件
3.6.0.1
原生动物
生成源
跑
3.6.0
主要的
src/main/protobuf
src/main/protobuf

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

结果表明,由于这种类型不是标准类型之一,Maven插件需要额外的配置才能工作,即
direct
参数,如下所示:

<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>
                        <includeMavenTypes>direct</includeMavenTypes>
                        <includeDirectories>
                            <include>src/main/protobuf</include>
                        </includeDirectories>
                        <inputDirectories>
                            <include>src/main/protobuf</include>
                        </inputDirectories>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

com.github.os72
ProtocJarMaven插件
3.6.0.1
原生动物
生成源
跑
3.6.0
主要的
直接的
src/main/protobuf
src/main/protobuf
通过这种配置,proto文件可以编译