[Active] REST web service using Spring JPA, Spring MVC and Spring Boot.
- 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
-
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
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
andspring.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
- The app will start running at http://localhost:8080.
- The REST service is running at http://localhost:8080/api/v1.0.
- The current version of the API is v1.0.
- Creating a new Person using POST /api/v1.0/persons API
- localhost:8080/api/persons/
- Example: {"firstName": "Gonzalo", "lastName":"Martinez"}
- Retrieving all Persons using GET /api/v1.0/persons API
- localhost:8080/api/persons/
- Retrieving a single Person using GET /api/v1.0/persons/{personId} API
- localhost:8080/api/persons/1
- Updating a Person using PUT /api/v1.0/persons/{personId} API
- localhost:8080/api/persons/1
- Example: {"firstName": "Frederic", "lastName":"Chopin"}
- Deleting a Person using DELETE /api/v1.0/persons/{personId} API
- localhost:8080/api/persons/1