4

This is my .proto file

syntax = "proto3";

package testing;

option java_multiple_files = true;
option java_package = "com.api.commons.proto";
option java_outer_classname = "SampleProto";

message Person {
  string name = 1;
  int32 id = 2;
  string email = 3;

  enum PhoneType {
    MOBILE = 0;
    HOME = 1;
    WORK = 2;
  }

  message PhoneNumber {
    string number = 1;
    PhoneType type = 2;
  }

  repeated PhoneNumber phones = 4;
  map<string, string> map = 5;                                                                                                                                                                                                        
}

When I try to compile the proto file, the proto related java files create successfully. but open that file I see the error method. I am given below to attach that error case.enter image description here

Now I am changing all fields to optional this error case not reproduced... My doubt is in proto3 all fields by default optional then why this issue fixed, when I change all fields to optional. Thanks

Alex Sparrow
  • 197
  • 2
  • 7
  • 2
    My guess is that you're using a version of the jar file that supports protobuf that doesn't match the protoc version you're using. – Jon Skeet Oct 22 '21 at 06:24

0 Answers0