Structuring a Spring Boot Application21 May 2015
Two of the main aspects of Software Design and Architecture are Separation of Concerns and Dependency Management. In his post about Clean Architecture, Uncle Bob explains how to achieve separation of concerns dividing the software into layers following The Dependency Rule.
Using the Clean Architecture concept I’ve used Spring Boot and Gradle Multi-Project Build to create a example application divided into projects that have clear concerns/responsibilities and follow The Dependency Rules.
The example uses Spring Boot and Jersey to create a standalone application that exposes a RESTful endpoints. This is a simple example, but it can be easily transferred to a real-world applications (a Microservices for example).
Projects and Concepts
- multi-projects: the root project with the plugin definitions and the common dependencies.
- service-app: responsible for configure and run the application execution.
- service-endpoints: It has the versioned endpoints.
- service-implementation: It encapsulates the application specific business rules.
Depending on the need, this structure can be composed by more then these four projects, the important thing is to have projects with a clear concept following The Dependency Rule. The idea behind the use of this kind of structure is to make a reinforcement of where the developers have to put their code aiming the loose coupling and a clear separation of concerns.