2017-09-01 39 views
1

当我尝试编译要转换为.java的原始文件时出现错误。
你能指出我错过了什么吗?导入另一个原始文件时出错

protoc --proto_path=src\main\resources\proto --java_out=src\main\java src\main\resources\proto\PayloadProtocol.proto 

PayloadProtocol.proto:32:14: "DataContainer" is not defined. 
PayloadProtocol.proto: warning: Import BackendCommunicationService.proto but not used. 

Payload.proto

import "BackendCommunicationService.proto"; 
package com.fleetboard.tp.payload.protocol.protobuf; 

option java_package = "com.fleetboard.tp.proto.protocol"; 
message TPMessage { 
     required int32 serviceId    = 1;     // telematic service (TS) id, who owns this message 
     required int32 functionId    = 2;     // function id refers to the Java class for the payload 
     optional uint64 requestId    = 3;     // Identifier to associate the request to a response 
     optional TPPayload payload    = 4;     // serialized representation of a TP message 
     optional uint64 durability    = 5;     // life time of message - used from backend 
     optional DataContainer dataPayload  = 6;** 
    } 

BackendCommunicationService.proto

package com.fleetboard.tp.backend.protobuf;  
option java_package = "com.fleetboard.tp.proto.backend"; 

    message DataContainer { 
     required DeviceApplication application = 1; // The container's recipient (MT) or sender (MO) 
     required string fileName = 2;    // File name (no path), length up to 255 
     required uint64 fileTime = 3;    // File time as ms since 1970-01-01 00:00 UTC 
    } 

回答

1

完全在导入文件限定名称:

com.fleetboard.tp.backend.protobuf.DataContainer 

.com.fleetboard.tp.backend.protobuf.DataContainer 

(在.确保它从根开始)

你也可以尝试使用只是不相交的部分,但我不知道这是否会工作:

backend.protobuf.DataContainer 

(因为两者都有前缀com.fleetboard.tp.