maven - 从同一文件夹中的另一个 proto 文件导入 proto 文件
问题描述
我已经经历了一些以前提出这个问题的问题,但我仍然被困住了,所以我希望能就我遇到的问题获得一些具体的建议。底部有相关代码的 Pastebin 链接。我正在使用 Java 编写稍后编写的代码,JavaSE - 1.8,我正在使用 Maven 进行编译
我对 gRPC 很陌生,但我认为我对这些原则有相当扎实的把握,而且我之前尝试过的示例都很成功。我正在尝试在一个原型中编写一个类作为消息,这样我就可以在其他几个中使用它。在我的梦想中,我会在另一堂课上重复这个,但我已经停滞了几天试图正确导入文件。
我想我已经正确导入了文件,但是当我尝试编译时,无法根据此消息为元素本身正确写入文件路径
the.proto:29:9:“房间”未定义。the.proto:警告:导入 room.proto 但未使用
这可能意味着文件已找到但元素尚未找到。老实说,与之前发生的事情(没有识别)相比,这一步是由反复试验引起的改进。我试图链接“房间”的文件路径不断变化,因为我真的不知道该怎么做。尝试过同学和网上的建议,但没有任何效果
proto 文件在同一个文件夹中,它们不在一个包中,而是在项目名称下,然后是 src/main/resources。
proto 文件的文件路径(根据 room.proto 的属性)是 /officeally/src/main/resources/room.proto
/////////////////////////////////////////////////////////////////////////////////////////
Room Proto
//////////////////////////////////////////////////////
syntax = "proto3";//Must be Proto3
package officeally.src.main.resources;
option java_package = "com.myoffice";//must match group ID from proto
option java_multiple_files = true;//Do not change this. Creates multiple generated classes
option java_outer_classname = "OfficeAlly";//Corresponds to projectname. Name is created here
message Room{
enum Location{
Unknown = 0;
Hallway = 1;
MaleWC = 2;
FemaleWC = 3;
Office = 4;
Kitchen = 5;
ConferenceRoom = 6;
}
Location room = 1;
int32 capacity = 2;
int32 population = 3;
bool light = 4;
}
///////////////////////////////////////////////////////////
PROTO that imports room
/////////////////////////////////////////////////////////////////////////////
syntax = "proto3";//Must be Proto3
option java_package = "com.myoffice";//must match group ID from proto
option java_multiple_files = true;//Do not change this. Creates multiple generated classes
option java_outer_classname = "OfficeAlly";//Corresponds to projectname. Name is created here
import "room.proto";
service lightandtempcontrol {
//create a name for the rpc first -> then specify type of message to send to server
// to turn a light on upon somebody entering a room
rpc LightsOn(targetLight) returns (emptyMessage) {};//Unary*
// to turn a light off upon someone entering the room
rpc LightsOff(targetLight) returns (lightReceipt) {};
//to regulate temperature dependent on the temperature outside
rpc OutsideTemp(stream outTemp) returns (stream indoorTemp){};//Bidirectional*
//to get a complete
rpc Usage(usageRequest) returns (stream lightUsage) {};//Server streaming example
}
message targetLight{
//Location to be turned on
Room targetRoom = 1;
bool light = 2;
}
如果有任何其他信息我可以添加,请告诉我。我不确定需要什么