Spring Boot H2 简明教程
Spring Boot & H2 - REST APIs
与上一章 Application Setup 一样,我们在 Spring Boot 项目中创建了所需文件。现在在 POSTMAN 中创建以下集合来测试 REST API。
As in previous chapter Application Setup, we’ve created the required files in spring boot project. Now create the following collection in POSTMAN to test the REST APIs.
-
GET Get All Employees − A GET request to return all the employees.
-
POST Add an Employee − A POST request to create an employee.
-
PUT Update an Employee − A PUT request to update an existing employee.
-
GET An Employee − A GET request to get an employee identified by its id.
-
Delete An Employee − A Delete request to delete an employee identified by its id.
Add an Employee
在 POSTMAN 中设置以下参数。
Set the following parameters in POSTMAN.
-
HTTP Method − POST
-
BODY − An employee JSON
{
"id": "1",
"age": "35",
"name": "Julie",
"email": "julie@gmail.com"
}
Update an Employee
在 POSTMAN 中设置以下参数。
Set the following parameters in POSTMAN.
-
HTTP Method − PUT
-
BODY − An employee JSON
{
"id": "1",
"age": "35",
"name": "Julie",
"email": "julie.roberts@gmail.com"
}
GET An Employees
在 POSTMAN 中设置以下参数。
Set the following parameters in POSTMAN.
-
HTTP Method − GET
-
URL - http://localhost:8080/emp/employee/1 − Where 1 is the employee id
Delete An Employees
在 POSTMAN 中设置以下参数。
Set the following parameters in POSTMAN.
-
HTTP Method − DELETE
-
URL - http://localhost:8080/emp/employee/1 − Where 1 is the employee id