Home > Java > javaTutorial > body text

REST CRUD API

PHPz
Release: 2024-09-03 17:10:02
Original
567 people have browsed it

REST CRUD API

1. What are REST Services

-> A lightweight approach of communication between different apps
-> REST is language independent
-> REST works with any data format, but JSON is the most popular

2. JSON

  • An object:
{
   "name": value
}
Copy after login
  • Names of the object's attributes are always in double quote, value is in double quote if it is a string

  • 4 HTTP methods: Post(Create), GET(Read), PUT(Update), DELETE(delete)

3. Spring Rest Controller

Development process:

  1. Add Maven dependency for Spring Boot starter web
  2. Create Spring Rest Service using @RestController (manually), instead you can use Rest's auto configuration, see in section 6

4. API Desgin Process

  1. Review API's requirements
  2. Identify main entity/resource
  3. Use Http methods to assign action on resource

5. Spring JPA

Automatically give CRUD operations on entities

  1. Extend JPARepository interface and plug in your entity and primary key
  2. Use your repository

6. Spring Data Rest

You only need to add spring-boot-starter-data-rest dependency to your pom.xml file, Spring will give REST CRUD operations

The above is the detailed content of REST CRUD API. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!