Файл, содержащий операторы импорта.
import "goproto/common/date.proto";
import "goproto/common/timestamp.proto";
import "goproto/common/custom_options.proto";
option java_multiple_files = true;
option java_package = "com.kafka.proto";
message KafkaInfoLogProto {
int32 pid = 1;
com.types.Timestamp event_time = 2;
string tid = 3;
string device_id = 4;
string email = 5;
string city_id = 6;
com.types.Date check_in = 7;
com.types.Date check_out = 8;
}
Прото-файлы импорта находятся в другом каталоге с именем common, и, например, позвольте мне описать один из импортируемых прото-файлов.
syntax = "proto3";
package com.types;
option java_multiple_files = true;
option java_outer_classname = "DateProto";
option java_package = "com.types";
message Date {
int32 year = 1;
int32 month = 2;
int32 day = 3;
}
Мой pom-файл выглядит так:
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</dependency>
</dependencies>
И используемый плагин:
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.6.1:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.19.0:exe:${os.detected.classifier}</pluginArtifact>
<attachProtoSources>true</attachProtoSources>
<includeDependenciesInDescriptorSet>true</includeDependenciesInDescriptorSet>
<protoSourceRoot>../goproto/</protoSourceRoot>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
Ошибка, которую я получаю.
[ERROR] /goproto/aug/kafka_info_log.proto [0:0]: goproto/common/date.proto: File not found.
goproto/common/timestamp.proto: File not found.
kafka_info_log.proto: Import "goproto/common/date.proto" was not found or had errors.
kafka_info_log.proto: Import "goproto/common/timestamp.proto" was not found or had errors.
kafka_info_log.proto:16:5: "com.types.Timestamp" is not defined.
kafka_info_log.proto:21:5: "com.types.Date" is not defined.
kafka_info_log.proto:22:5: "com.types.Date" is not defined.
Я уже искал в Интернете об этом, но не мог найти никакого решения. Пожалуйста, помогите в этом.