DEV Community

sanjay shivanna
sanjay shivanna

Posted on

Springboot Project Structure

In this short article we will try to explore some of the discussions around best practices for packages

Project by code structure

alt text

Above structure defined is more a classic structure followed mostly :) ... (At least on the projects that I worked on)

Project by feature structure

alt text

package by feature

Follow this article which more are less explains the spring pet clinic project structure.
https://www.baeldung.com/spring-boot-package-structure

package by code structure

Below is the good article I found about project by code structure, if you find anything better, please comment.
https://medium.com/the-resonant-web/spring-boot-2-0-project-structure-and-best-practices-part-2-7137bdcba7d3

which ever approach you choose from above for enterprise you would like to standardize the project structure for all the development team and provide some template classes. If you are using maven you can do this by arch-type.

Maven Archtype

We can use maven archtype to create structure. Personally I feel it's important in enterprise to have a common structure defined for consistency and readability perspective.

Good Articles to follow for creating a maven archtype.

https://rieckpil.de/create-your-own-maven-archetype-in-5-simple-steps/

https://maven.apache.org/guides/mini/guide-creating-archetypes.html

https://medium.com/@inthiraj1994/creating-your-own-archetype-840136fc7818

https://www.javacodegeeks.com/2019/05/creating-custom-maven-archetype.html

you can also use IntellIJ feature for storing project templates locally for future reference.
https://www.jetbrains.com/help/idea/saving-project-as-template.html

In this article I try to summarize the package structure and how we can use maven archtype to create our package structures and templates.

Top comments (0)