Skip to content
Advertisement

Geting list of protobuf message objects from the SpringBoot

I want to get a list of protobuf message objects from the Spring boot app.
I did manage to get a single protobuf message object from the app but getting a list of them throws exception.

JavaScript

My code (simplified).

tl;dr

  • create Spring boot app
  • generate class from proto file
  • try return List of generated class objects (RESTful)

My code (simplified).
Controler

JavaScript

App

JavaScript

pom.xml

JavaScript

I generate message objects using:

JavaScript

proto file

JavaScript

I did found simmilar issue but it had no solution.

Advertisement

Answer

Workaround
I couldn’t find a solution to the problem so came up with a workaround.
Instead of returning generated protobuf message objects I returned wrappers for those objects. Using Lombok annotation it could be done:

JavaScript

This workaround doesn’t feel very bad as it uses standard Spring boot dependencies.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement