https://github.com/rodrigobalazs/springboot-rest-sql
https://github.com/rodrigobalazs/springboot-rest-sql
api-rest docker java junit maven springboot springdata
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rodrigobalazs/springboot-rest-sql
- Owner: rodrigobalazs
- License: mit
- Created: 2024-10-13T17:29:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-25T20:52:58.000Z (10 months ago)
- Last Synced: 2026-01-03T21:08:51.370Z (5 months ago)
- Topics: api-rest, docker, java, junit, maven, springboot, springdata
- Language: Java
- Homepage:
- Size: 158 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Spring Boot REST API
This repository contains an Spring Boot Store Application. The app provides a REST API related to Categories and
Products associated to the Categories.
Although the domain model is very simple, the goal is to provide examples of Spring related technologies, like
Spring Boot, Spring Data, etc.
### 🔧 Technology Stack
```
Java 17
Spring Boot 3 ( REST API )
Spring Data ( MySQL )
Testing ( Junit 5 / Mockito / TestContainers )
Misc Libraries ( Maven / Docker / SpringDoc OpenAPI / Apache Commons / Lombok )
```
### ⚒️ Getting Started
```bash
# clone the project
git clone https://github.com/rodrigobalazs/springboot-rest-sql.git;
cd springboot-rest-sql;
# start a mysql docker container
docker run --name store_db -e MYSQL_DATABASE=store_db -e MYSQL_USER= \
-e MYSQL_PASSWORD= -e MYSQL_ROOT_PASSWORD= \
-p 3306:3306 -d mysql:latest;
# make sure to update application.properties with the
# MYSQL_USER and MYSQL_PASSWORD values defined in the previous point
spring.datasource.username=
spring.datasource.password=
# compile and start the spring boot server
mvn clean install;
mvn spring-boot:run;
```
### 💡 API Examples
#### 1. Get all the available Categories =>
```
curl -X GET http://localhost:8080/category/getCategories -H 'accept: application/json';
```
#### 2. Retrieves a Category by Category Name =>
```
curl -X GET http://localhost:8080/category/name/Furniture -H 'accept: application/json';
```
#### 3. Deletes a Category by Category id =>
```
curl -X DELETE http://localhost:8080/category/id/1 -H 'accept: application/json';
```
#### 4. Creates a new 'Sports Equipment' Category with an associated Product =>
```
curl -X POST http://localhost:8080/category \
-H 'accept: application/json' \
-H 'Content-Type: application/json' -d \
'{
"name": "Sports Equipment",
"products": [
{
"name": "Triathlon Suit",
"price": 250.1
}
]
}';
```
#### 5. Updates the product 'Sweater Tangle Essential' price from $50.4 to $90.8 =>
```
curl -X PUT http://localhost:8080/category/id/2 \
-H 'accept: application/json' \
-H 'Content-Type: application/json' -d \
'{
"name": "Clothing",
"products": [
{
"id": 4,
"name": "Sweater Tangle Essential",
"price": 90.8
}
]
}';
```
### 🔍 API Documentation / Swagger
the API documentation could be accessed from => http://localhost:8080/swagger-ui/index.html
