java, spring boot Autogenerate getters and setters at runtime

13.4k views Asked by At

I have a set of bean classes. I would like to know the best approach to generate the getters and setters automatically at run time. Can anyone help please.

3

There are 3 answers

0
Matt Berteaux On

I'm not aware of a way to generate the getters/setters at runtime, but Lombok has annotations that you can add that will generate the getters/setters for you at compile time. It is a pretty seamless experience. Lombok can also generate builder classes, toString, equals/hashCode methods.

1
Sambit On

You can use Lombok which generates getter, setter, toString methods at runtime. It is a powerful and very helpful library. I provide below the link.

https://projectlombok.org/

1
Nic On

After you have created the variables in the class, right click, select Source, select Generate Getters and Setters.