This is very simple spring boot project for demonstrating Spring boot capabilities. Please refer below documentation for more details about the technical stack, tools, local setup, test cases etc.
- There are two entities called
Product
andClient
- Java generic is used wherever it's effective to reduce code duplication and so easy to maintain and scale
Product
can't be hard deleted, and so can be retrieved even after deleted with boolean flag calledincludeDeleted
Client
cab be hard deleted normally- App is ready to run with pre-populated data
H2 database used, and actual data will be stored using file system in the /target folder. While running integration tests, the data will be stored in the memory. Please visit http://localhost:8080/h2-console/ to access database console.
Flyway is used for database migration, refer SQL files inside the resources/db/migration folder. There are some data pre-populated in the one of migrations so application will have always some data to play around on startup.
- Spring Boot 2.7.2 (latest from 2.x as of 06 Aug 2022)
- Java 11
- Maven
- H2
- Flyway
- JUnit 5
- Jacoco
- Lombok
There are multiple ways you can run the project based on your purpose/requirements.
- Using IDE: Just import project as Maven project in your favourite IDE and run as Application, no extra step required
- Using Command Line without an external jar (recommended only for local):
mvn clean spring-boot:run
- Using Command Line with an external jar (recommended on cloud): a)
mvn clean package
b)java -jar target/demo-0.0.1-SNAPSHOT.jar
mvn clean
- Run the application using your favourite method as described in above question
mvn clean test
- Open
target/site/jacoco/index.html
with any browser and check report
- There are all layers (i.e. resource, service, repository) unit + integration test cases have been written and current code coverage with Jacoco is 97%
- There are no spring profiles used as there were no such requirements, so it will be always "default" profile used
- There are no create end-points implemented but as mentioned in DB migration section, there will be always some data pre-populated