Spring Boot JPA
Spring Boot provides spring-boot-starter-data-jpa starter to connect Spring application with relational database efficiently. You can use it into project POM (Project Object Model) file.
Here, we are creating a spring-boot application which uses JPA to connect to the database.
Spring Boot provides default server and apache derby database. So, we will use that in our application.
Now, let's create project. Follow the following steps.
Select project type
Provide project name.
After finishing, create the following files.
Our project looks like the following.
Now, run the application.
Here, we are using Postman plug-in of the Firefox browser to test our application. Postman is a nice tool which provides interface to request HttpRequests. You can download it from the official site of Firefox.
Providing URL on which application is running. After that selecting HttpRequest method.
Submit the request.
After submitting, it returns a blank array as response because initially there is no data into the database.
Adding data into the repository.
Providing a new URL for adding user and data to insert. Select POST method and submit.
After submitting, it returns response code 200 which means data has inserted successfully.
Now, fetch the inserted record by changing the request URL.
Notice that after submitting, it returns inserted data in response box.
Well, we have created Spring Boot application by using JPA successfully.