r/SpringBoot • • Jun 29 '24

Well Structured Projects

Hello, I am looking for some well-structured Spring Boot projects to learn the best practices of the framework. I would really appreciate any recommendation.

25 Upvotes

25 comments sorted by

View all comments

Show parent comments

-3

u/Aggravating_Crazy_65 Jun 29 '24

what? usually controllers class are inside a controller package

1

u/WaferIndependent7601 Jun 29 '24

No. Very bad style

1

u/Aggravating_Crazy_65 Jun 29 '24

why? you can have 2 package structure

  • entity package oriented

  • layer package oriented

If you choose the second, you have the following: controller/service/component/entity

if you take the entity oriented: user package and inside the layer classes.

Is just conventions, and inside a project, when you choose one or create your own with your team, everything it's fine.

the package is not the software (which is the real reason for what we are doing)

-1

u/WaferIndependent7601 Jun 29 '24

You can also put everything in one package. But this is also not the best possible solution.

I know that this was done 10 years ago. But we learned from that and should use packages use case wise. It’s so much easier to understand the project. If you stay in the same project all your life it’s ok. If you change projects you don’t want all controllers in one package.

You can also simply move the package to a new service.

1

u/Aggravating_Crazy_65 Jun 29 '24

yeah, I mean, depends on the project; for example I use the "entity" package or the solution you are talking, where I need to work with monolith application, which help me more to find the wanted classes.
If i work on a microservice architecture, i just use the classic layer structure, because i usually have only one rest controller.

0

u/WaferIndependent7601 Jun 29 '24

If you have only one controller: don’t put it in any package. And in the end: your microservices have the same package structure as your modolith.

That’s also the reason why microservices are not an architecture but a deployment strategy

1

u/Sheldor5 Jun 29 '24

sounds good, doesn't work in reality ...

1

u/WaferIndependent7601 Jun 29 '24

What exactly does now work? I did this multiple times.

1

u/Sheldor5 Jun 29 '24

so your projects and data structures aren't that big ...

-1

u/WaferIndependent7601 Jun 29 '24

Where did I say that?

Good projects don’t get too big. That’s what a good dev should always have in mind and split the project and teams

→ More replies (0)