user5448913
user5448913

Reputation:

Protocol Buffers packages issue

I am new to Protocol Buffers, and I have just added the library / build requirements for my Maven project. I now have a .proto file in my source repository that has little to nothing in it:

package com.christopher.kade;
option java_package= "protocol";

message Protocol {
    required int32 id = 1;
    required string name = 2;
}

But I've found myself facing a problem when it comes to packages, the following file creates a protocol package in my com.christopher.kade one and I get an error message stating that:

Package name 'protocol' does not correspond to the file path 'com.christopher.kade.protocol'.

What is the good approach in order to generate my class in my current package? Therefore I would have:

com.christopher.kade
|- client.proto
|- MyGeneratedClass.java
|- MyClass.java

Upvotes: 1

Views: 73

Answers (1)

Srinikhil Reddy
Srinikhil Reddy

Reputation: 15

The mistake is in this line

option java_package= "protocol";

Change it to

option java_package= "com.christopher.kade";

and you are good!

Upvotes: 1

Related Questions