Spring Boot and H2 database demo project
- Navigate to https://start.spring.io.
- Choose either Gradle or Maven and the language you want to use. I have used Maven in this application.
- Click Dependencies and select Rest Repositories, Spring Data JPA, and H2 Database.
- Click Generate.
- Add the relevant classes such as Controller, Repository & Entity class.
mvn clean install
mvn spring::boot run
Created a Dockerfile with the below contents:
FROM eclipse-temurin:17-jdk-alpine
VOLUME /tmp
COPY target/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
docker --version
docker build -t myorg/myapp .
docker run -p 8080:8080 myorg/myapp
Add the customers by using below link: http://localhost:8080/newcustomer
Get the list of customers:
http://localhost:8080/customers
🌻Yay! We created and dockerized a Spring Boot application.
Thank you for visting! Happy Learning!