SpringBoot ProjectSetup and Layered Architecture
Go to start.spring.io
Select Java and maven and stable version of springboot and fill project metadata.
Jar(java archive) microservice standalone java application vs War(web archive) -- complete html css js included (complete bundle).
Jar is preferred for most of the cases.
Dependencies (start with springweb ) should be sufficient to start with restful apis.
later add dependencies to pom.xml which is present.
Create basic initial layers.
Controller layer -> @Controller @RestController , starting point of api request.
Service layer -> @Service Annotation Make sure all the business logic goes to this layer.
Repository layer -> @Repository basically make sure to connect to database from this layer. Fetch data from database and return to service layer.
Apart from layers there are few additional packages which can be created as part of standard process.
DTO , Utility , Entity, Configuration.
Data transfer object.(request DTO and response DTO).
Controller layer takes responsibility of mapping.
Utility layer put anything which is common across layers, like common methods and other stuff.
Entity @entity direct representation of table.
Configuration (application.properties) any hard coded values which can be changed later at a single place.