r/SpringBoot • • Sep 29 '24

Package structure

Post image

What do you think about this package structure? What packages or layers would you add or remove if you work with microservices architecture?

43 Upvotes

43 comments sorted by

View all comments

13

u/g00glen00b Sep 29 '24

I think it's far too detailed. Even if code becomes more complex, it's still going to be a microservice, so I can't imagine the need for this structure. I would remove the deepst package level, so:

  • configuration.app + configuration.security = configuration

  • persistence.entity + persistence.repository = persistence

  • presentation.advice + presentation.controller + presentation.dto = presentation

  • service.http + service.implementation + service.interfaces = service

  • util.mapper = util

Also, I'd argue that your exceptions are part of your presentation layer. A DTO is used in the presentation layer when something went successful, and an exception if something didn't go successful.

1

u/HappyPurchase72 Sep 29 '24

I liked this proposal, thanks. I didn't know that the exception package could go in the presentation layer, I didn't think of it that way.