- What we will build
- Tech Stack
- Create Project
- Package Structure
- Dependency
- API Test
Build a CRUD rest APIs using Spring boot, spring data JPA, Hibernate and MySQL database.
- [1]
- 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.
The simplest way is to use spring initializr for create spring boot app.
go : https://start.spring.io and generate .
<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
[1] https://hemant-jain-42745.medium.com/restful-api-a7a19ca387d0