Spring Boot Data JPA Rest API

Spring Boot Data JPA Rest API is a full package Spring Boot applicaiton for RESTful API Endpoints Creation. Using the quick and ready for production features of Spring Boot with Spring Data JPA and Hibernate, this application becomes complete package which is easy to use and extendable.

In this post, we will see how we can execute a simple program for RESTful APIs using Spring Boot and Data JPA with Hibernate.

  • Prerequisite

Java must be installed first.
You will also need Maven Setup done already on your machine.
You will need an IDE like Eclipse to build and execute the project.
You will also need the MySQL to be installed in the same machine.

Find the Source Code on GitHub: Spring Boot Data JPA Rest API.

  • Spring Boot Data JPA Rest API Program

Once above pre-requisites are done, either use the GitHub project to clone and execute. Check program instructions as below.

  1. Once the JDK and Maven setup is done. In any of the empty directory checkout the Git project for SpringBootRestApiDataJPA. This will be your workspace with eclipse to execute or modify the SpringBootRestApiDataJPA Java Source code.

    Spring Boot Data JPA Rest API Java Maven Project

  2. The SpringBootRestApiDataJPA program will be created in Eclipse and it will have /src/main/java/
    folder for writing java source code.
    Create database in MySQL using create database empDB query in any Database Client tool like Workbench.

    Now, run the Maven command from this Project folder to build the project and run, mvn spring-boot:run.

    Alternatively, the package can be created and run using below command.
    mvn package
    java -jar target/SpringBootRestApiDataJPA-0.1.jar

    Then use the URL
    http://localhost:8080/api/v1/employees to execute
    and see the result on browser. The default port in inbuilt tomcat with Spring Boot is 8080.
    See simple example result for all employees result as JSON in Postman tool.

    Find the Postman Result for GET Request.
    SpringBootRestApiDataJPA Postman GET Result

    Find the Postman Result for POST Request.
    SpringBootRestApiDataJPA Postman POST Result

    So here we are done with the first program for Spring Boot plus Data JPA and Hibernate.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.