An API REST build using SpringBoot.
-
Languages: Java.
-
DataBase: MySQL.
-
Framework: SpringBoot.
-
Libraries: SpringWeb, JPA, MySQL Driver, Lombok.
-
Download this repo in your local machine.
-
Create a MySQL Database with the following command:
CREATE DATABASE your_db_name;
-
Move inside this dir:
cd /path_to_this_repo/src/main/resources
-
Change this configuration and paste it inside application.properties:
spring.datasource.url=jdbc:mysql://localhost/your_db_name?useSSL=false&serveTimeZone=UTC spring.datasource.username=your_user_name spring.datasource.password=your_user_password spring.datasource.driver-class=com.mysql.cj.jdbc.Driver spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect spring.jpa.hibernate.ddl-auto=update logging.level.org.hibernate.SQL=debug
-
Move inside the root folder of this repo.
-
Execute the follow command:
- MacOS/Linux:
./mvnw spring-boot:run
- Windows:
mvnw spring-boot:run
-
Use any of the follow CRUD methods with the follow structure in your api tester or code:
-
GET:
- To get all from the DB: http://localhost:8080/api/user.
- To get a specific user from the DB: http://localhost:8080/api/user/{id_of_requested_user}.
-
POST:
{ "firstName": "first_name_as_string", "lastName": "last_name_as_string" }
- To create a new user in the DB, send the JSON above to this address: http://localhos:8080/user.
-
UPDATE:
{ "firstName": "new_first_name_as_string", "lastName": "new_last_name_as_string" }
- To update a user data, send the JSON above to this address: http://localhos:8080/user/{id_of_requested_user}.
-
DELETE:
- To delete a specific user from de DB, send the follow request: http://localhost:8080/user/{id_of_requested_user}.
-