Skip to content

:person_with_pouting_face: [Active] REST web service using Spring JPA, Spring MVC and Spring Boot. Including GET, POST, PUT, DELETE operations.

License

Notifications You must be signed in to change notification settings

gmartinezramirez-old/Spring-API-REST-Person-CRUD

Repository files navigation

REST Web Service for CRUD operations

[Active] REST web service using Spring JPA, Spring MVC and Spring Boot.

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Build Status Codacy Badge

  • Spring web service of a CRUD of persons using Spring JPA, Spring MVC and Spring Boot, including GET, PUT, POST and DELETE operations for a person entity.
  • Attributes: firstname and lastname.

Requeriments | How to run | How to use the API

Requeriments

  • Java - 1.8.x

  • JDK or OpenJDK - 1.8.x

  • Maven - 3.x.x

  • MySQL - 5.x.x or MariaDB 10.x.x

  • Spring - 2.0.0.RELEASE (inclued in pom.xml)

  • Tested on:

  • GNU/Linux Solus 3

  • JDK 1.8.0_161

  • Linux Kernel 4.15.6-58.current

  • MariaDB 10.1.29

How to run

1. Clone the repository.

git clone https://github.com/gmartinezramirez/Spring-API-REST-Person-CRUD.git

2. Create the database "persons" in MySQL or MariaDB.

mysql -u root -p
mysql> create database persons;

3. Change mysql username and password as per your installation

  • open src/main/resources/application.properties.

  • change spring.datasource.username and spring.datasource.password as per your MySQL installation.

  • by default the user is: 'root' and password is: '1234' (without the ').

spring.datasource.url = jdbc:mysql://localhost:3306/persons?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
spring.datasource.username = root
spring.datasource.password = 1234

4. Build and run the app using Maven

mvn package
java -jar target/person-1.0.0.jar

  • Also, you can run the app without packaging it using:
mvn spring-boot:run
  • Also, you can run the app without packaging it using:
./run.sh

How to use the API

  • The current version of the API is v1.0.
  1. Creating a new Person using POST /api/v1.0/persons API
  • localhost:8080/api/persons/
  • Example: {"firstName": "Gonzalo", "lastName":"Martinez"}

  1. Retrieving all Persons using GET /api/v1.0/persons API
  • localhost:8080/api/persons/

  1. Retrieving a single Person using GET /api/v1.0/persons/{personId} API
  • localhost:8080/api/persons/1

  1. Updating a Person using PUT /api/v1.0/persons/{personId} API
  • localhost:8080/api/persons/1
  • Example: {"firstName": "Frederic", "lastName":"Chopin"}

  1. Deleting a Person using DELETE /api/v1.0/persons/{personId} API
  • localhost:8080/api/persons/1