Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
How to reuse code/functionality from multiple Spring Boot applications?
1 point by ajalife on July 26, 2023 | hide | past | favorite
I'm developing multiple applications (API's) with Spring Boot and some of them are only used by some specific clients. The problem is that I'm having to duplicate code and functionalities between different API's and I dont know how to reuse the code in them.

For an example, I have a main API that every client used and it has multiple model/dto/services/controller. I have another API that's specific for one client (and I dont want to have that in my main API, because some clients dont need it) that neeeds some of the main API entities.

Should I unify the applications and find a way to separate them inside one project, or how could I reuse these entities between the different applications?

Is creating a library with the main models, dtos, exceptions the best way here?

One question I have with creating a library is, when im developing one API that uses this library, I have to have the library compiled? or it can use a non-compiled version?

Im asking this because it could make the development process more slow for the team (if we have to recompile everytime we make a change in the library).

Thank you.



Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: