Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need a way to generate Java classes for Spring Boot

I’m trying to build an administration portal accessible via web starting from the informations inside a database using Spring Boot with MyBatis for accessing the database. I wanted to find a way to reuse the code that I’m building for the portal with any other type of database, so I was wondering if there was a way to automatically generate classes for my project starting from the informations in the database, for example table names and fields... Thanks in advance!

like image 506
Mario F Avatar asked Dec 19 '25 03:12

Mario F


2 Answers

Telosys code generator (http://www.telosys.org) does this kind of job.

It uses the database schema to create a lightweight model that is used to generate the code (Java or any other language).

For more information see : https://modeling-languages.com/telosys-tools-the-concept-of-lightweight-model-for-code-generation/

Everything is Open Source (tool and templates)

like image 198
lgu Avatar answered Dec 21 '25 18:12

lgu


An option could be Jassd, which generates POJOs, Dao interfaces, and Dao implementation classes from a database. Use what you want from the output and discard the rest, the aim of this project was to not have to manually write getters and setters and have something to start from.

See the documentation and sample output at https://github.com/aforslund/jassd

(Note: I am the author, implemented this library to be able to get plain old Java objects generated and bootstrap som Dao/DaoImplementation classes using plain SQL and JDBCTemplate with Spring Boot).

like image 39
Andreas Forslund Avatar answered Dec 21 '25 17:12

Andreas Forslund