项目作者: scbushan05

项目描述 :
This is the example that shows you how to build spring boot REST API that connects to MySQL database using Spring JdbcTemplate
高级语言: Java
项目地址: git://github.com/scbushan05/springboot-jdbctemplate-rest-api-mysql.git


Spring Boot REST API

This is the example project that shows you how to build Spring boot REST API that connects to MySQL databse using Spring JdcbTemplate.

Features

  • Create employee
  • List all employees
  • Fetch single employee by id
  • Update employee by id
  • Delete employee by id

API Reference

We will create a Employee REST API, following are the rest end points

Get all employees

  1. GET /api/v1/employees

Sample Response

  1. [
  2. {
  3. "id": 1,
  4. "name": "Bushan",
  5. "location": "India",
  6. "department": "IT"
  7. },
  8. {
  9. "id": 2,
  10. "name": "Bharath",
  11. "location": "India",
  12. "department": "Sales"
  13. },
  14. {
  15. "id": 3,
  16. "name": "Chaitra",
  17. "location": "India",
  18. "department": "IT"
  19. }
  20. ]

Get single employee

  1. GET /api/v1/employees/${id}
Parameter Type Description
id int Required. Id of employee to fetch

Sample Response

  1. {
  2. "id": 2,
  3. "name": "Bharath",
  4. "location": "India",
  5. "department": "Sales"
  6. }

Save employee

  1. POST /api/v1/employees
Parameter Type Description
employee reference Employee Required. Request body of employee

Sample Request

  1. {
  2. "name": "Bharath",
  3. "location": "India",
  4. "department": "Sales"
  5. }

Update employee

  1. PUT /api/v1/employees/${id}
Parameter Type Description
id int Required. Id of employee to update
employee reference Employee Required. Request body of employee

Sample Request

  1. {
  2. "name": "Bharath",
  3. "location": "India",
  4. "department": "Sales"
  5. }

Delete employee

  1. DELETE /api/v1/employees/${id}
Parameter Type Description
id int Required. Id of employee to delete

Installation

Download the project and import it to any IDE.
Open the class SpringbootjdbcApplication.java and run as Java application.

Demo

Insert gif or link to demo

Authors

Here are some related projects

Awesome README