Minimal example Spring Boot application
The followings are needed to build, test and run the project.
- Spring Web 🕸️
- Spring Data JPA 📓
- Spring Validation 💪
- Spring Boot DevTools ⚒️
- Lombok 🌶️
- H2 Database 🗄️
- JUnit 5 🧪
- Mockito 🍸
Follow the below instructions to build, test and run the project on your local machine.
Get started by cloning this repository using git command.
git clone [email protected]:Wanatchapong/springboot-example-service.git
And compile the project using the following maven command.
mvn compile
And build the project jar file using the following maven command.
mvn package
Unit test project using the following maven command.
mvn test
Run project using the following maven command.
mvn spring-boot:run
or run from the jar file
java -jar target/<projectname-version>.jar
- Compile source code and package it in its distribution format as JAR
mvn package
- Build docker image and tag the name of image
name:tag
. If not pass a tag, Docker uses "latest" as its default tag.
docker build -t springboot-example-service .
- Run docker image in detached mode
docker run -d -p 8080:8080 -t springboot-example-service
Open a terminal then make a GET
request to the server using the curl
command.
curl --request GET \
--url http://localhost:8080/todo \
--header 'content-type: application/json'