mtamerb / rest-api

Build a CRUD rest APIs using Spring boot, spring data JPA, Hibernate and MySQL database.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spring Boot, MySQL, JPA, Hibernate Restful CRUD API

Table of Content🚀️

  1. What we will build
  2. Tech Stack
  3. Create Project
  4. Package Structure
  5. Dependency
  6. API Test

1. What we will build

Build a CRUD rest APIs using Spring boot, spring data JPA, Hibernate and MySQL database.

RestApi Architecture

  • [1]

2. Tech Stack

  • Java - Java is a powerful general-purpose programming language-
  • Spring - The Spring Framework is an application framework and inversion of control container for the Java platform.
  • MySQL - MySQL Database is a client/server system that consists of a multithreaded SQL server that supports different back ends, several different client programs and libraries, administrative tools, and a wide range of application-programming interfaces (APIs).
  • Jpa -The Java Persistence API (JPA) is a specification of Java. It is used to persist data between Java object and relational database.
  • Maven - Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
  • Postman - Postman is an API platform for building and using APIs.
  • Lombok - Project Lombok (from now on, Lombok) is an annotation-based Java library that allows you to reduce boilerplate code.
  • Intellij Idea - IntelliJ IDEA is an Integrated Development Environment (IDE) for JVM languages designed to maximize developer productivity.

3. Create Project

The simplest way is to use spring initializr for create spring boot app.

go : https://start.spring.io and generate .

4. Package Structure

5. Dependency

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
	</dependency>

	<dependency>
		<groupId>org.projectlombok</groupId>
		<artifactId>lombok</artifactId>
		<optional>true</optional>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-jpa</artifactId>
	</dependency>
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<scope>runtime</scope>
	</dependency>

pom.xml

spring.datasource.url=jdbc:mysql://localhost:3306/testdb

spring.datasource.username=root

spring.datasource.password=password

spring.jpa.hibernate.ddl-auto=update

application.properties

6. Api Test

go : https://www.postman.com

References

[1] https://hemant-jain-42745.medium.com/restful-api-a7a19ca387d0

About

Build a CRUD rest APIs using Spring boot, spring data JPA, Hibernate and MySQL database.


Languages

Language:Java 100.0%