Hi guys,
This is my first post here. I have been working with spring boot for years. I would like to learn the best practice for structuring a spring boot project's codebase.
It would be awesome if you guys could help and I really appreciate it.
Hi guys,
This is my first post here. I have been working with spring boot for years. I would like to learn the best practice for structuring a spring boot project's codebase.
It would be awesome if you guys could help and I really appreciate it.
For further actions, you may consider blocking this person and/or reporting abuse
Advice from a career of 15+ years for new and beginner developers just getting started on their journey.
Mustapha Belmokhtar -
Kyle Pollock -
taijidude -
Aleksandr -
Once suspended, pkatul will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, pkatul will be able to comment and publish posts again.
Once unpublished, all posts by pkatul will become hidden and only accessible to themselves.
If pkatul is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Atul Kumar PK.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community safe. Here is what you can do to flag pkatul:
Unflagging pkatul will restore default visibility to their posts.
Oldest comments (3)
This could become very opinionated. But for my experience. I don't use the anonations of @Autowired, or and of the component scanning annonations such as @Component or @Service. All beans are created from @Configuration class and imported on the @SpingBootApplication. This also for building of beans via the constructor which makes them easy to test without spring in the test cases. It also provides more context around what is happening when spring boot is starting for those young developers to follow that are not familiar with spring boot.
As far as project structure. I start with 2 modules Applications and components.
Applications are your microservices. They contain your spring boot dependencies, controllers and message listener code. The idea is they take the information off the wire and passes it onto your service layer which is in your components module. This way if the delivery protocol changes you only need to change your application layer code.
Components are broken out into multiple modules. I usually have one or more core module. The core module contains all or most of my interfaces, not the implementations, any pojos needed for the interfaces, helper classes and utils. These are split on domains depending on project size.
Repository implementations are all separate by domain and technology. For example, a contact domain may have 2 modules one for JDBC and one for HTTP.
Then I have a service module for the repositories which is what the applications interface with if need be. If the service layer is just a pass-through then I forgo the service layer.