Best Practice for DTO-Mapping in Spring

Greetings, currently I'm part of rewriting an super old web-spring-boot-application in my company and would like to detach the request object from the business logic, because it's used like an Super-Object for everything. And there is this concept of DTOs, which seem to be the best practice for request objects anyways. Is there a best practice on how to map the DTO to my business-objects and the other way around in Spring-Boot-3?
5 Replies
JavaBot
JavaBot12mo ago
This post has been reserved for your question.
Hey @Lord Tkay! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Tomasm21
Tomasm2112mo ago
ModelMapper, MapStruct, and manual mapping. Each have their own use cases and advantages. For many Spring Boot 3 applications, MapStruct strikes a good balance between performance and ease of use, making it a popular choice. However, the best practice ultimately depends on your specific project needs and constraints.
Lord Tkay
Lord TkayOP12mo ago
Thanks for the answer. Based on what I've seen on a quick search of your libraries, the manual mapping seem to be the best bet at the moment. The request objects will be way different than my business-object in the beginning, because the whole request object need to be refactored anyway. But I will only do one application at a time.
JavaBot
JavaBot12mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
JavaBot
JavaBot12mo ago
Post Closed
This post has been closed by <@371310809755942925>.

Did you find this page helpful?