A well packaged basic implementation of springboot JPA using spring data and Java Persistence API's.
Original content from JavaTpoint, only change is the package organization.
Clone this repo to your local machine How To Guide
- Basic Knowledge of JAVA. Great tutorial on Javatpoint.
- Java JDK 8 at least installed locally Oracle Docs for Mac & Windows.
- Maven installed
- Basic knowledge of Springboot
- Postman
- Basics of Spring Annotations
Install all project dependencies with:
$ mvn install
Open a terminal and run the following commands to ensure that you have valid versions of Java and Maven installed:
$ java -version
$ mvn -v
You should get the versions of Java and Maven.
The Spring Boot Maven plugin includes a run goal that can be used to quickly compile and run your application. Applications run in an exploded form, as they do in your IDE. The following example shows a typical Maven command to run a Spring Boot application:
$ mvn spring-boot:run
####Using Executable Jar
To create an executable jar run:
$ mvn clean package
Testing - From JavaTpoint
Step 19: Open the browser and invoke the URL http://localhost:8080/. It returns an empty list because we have not added any user in the List.
To add a user to the database, we will send a POST request by using the Postman.
Step 20: Open the Postman and do the following:
Select the POST
Invoke the URL http://localhost:8080/add-user.
Click on the Body
Select Content-Type as JSON(application/json).
Insert the data which want to insert in the database. We have inserted the following data:
{
"id": "001",
"name": "john",
"email": "john@gmail.com"
}
When we click on the Send button, it shows Status:200 OK. It means the request has been successfully executed.
Step 21: Open the browser and invoke the URL http://localhost:8080. It returns the user that we have inserted in the database.