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

4

u/Aggravating_Crazy_65 Jun 29 '24

I think he is the best https://github.com/springframeworkguru he teach on udemy and have different courses about spring boot.

And, most important thing, never forget to read the docs :) https://spring.io/guides
You can find a lot of examples and start learn very in deep about REST api, DB interactions, Batch processing, Async with Reactor and TESTING!

1

u/WaferIndependent7601 Jun 29 '24

Controllers in controller package. Not so good

-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