【问题标题】:How to have import in .proto file of java project如何在 java 项目的 .proto 文件中导入
【发布时间】:2020-04-17 14:04:54
【问题描述】:

import 语句在 RED 中显示为 java 项目和可选参数 '[(validator.field) = {string_not_empty: true, length_lt: 255}];'也显示红色。 使用 Java8 + Gradle 项目


import "github.com/mwitkow/go-proto-validators/validator.proto";

package proto;

/**
The CryptoService takes a number of byte arrays and encrypts / decrypts them using Parcel Encryption.

*/
service CryptoService {
  // Encrypts an array of byte arrays
  rpc Encrypt (EncryptRequest) returns (EncryptResponse) {}

  // Decrypts a ciphertext to an array of byte arrays
  rpc Decrypt (DecryptRequest) returns (DecryptResponse) {}
}

message EncryptRequest {
  string alias = 1 [(validator.field) = {string_not_empty: true, length_lt: 255}]; // The alias that represents the private key
  string derivation_path = 2; // The derivation path to use
  repeated bytes data = 3; // One or more arrays of byte arrays containing the data you wish to encrypt ([][]byte)
}

message EncryptResponse {
  bytes data = 1; // The resulting ciphertext
}

message DecryptRequest {
  string alias = 1; // The alias that represents the private key
  string derivation_path = 2; // The derivation path to use
  bytes data = 3; // The ciphertext to decrypt ([]byte)
}

message DecryptResponse {
  repeated bytes data = 1; // An array of one or more byte arrays ([][]byte)
}```





【问题讨论】:

    标签: java gradle proto


    【解决方案1】:

    我为自己找到了一个解决方案,你可以先从网上下载 protobuf 文件(在本例中为validator.proto),然后将其保存在你的项目中以适应它!!!然后错误就消失了:-)

    【讨论】:

      猜你喜欢
      • 2021-11-16
      • 2020-06-25
      • 2020-11-17
      • 2012-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-16
      相关资源
      最近更新 更多