This repository implements a simple stock repository focused on basic CRUD operations that is backed by a MySQL database.
- Java 11+
- Maven 3.8+
- MySQL 8+
Navigate to the project root directory and run the following command.
mvn clean install
- Update the
src/main/resources/application.properties
file DB connection details. - For the initial run set value
spring.jpa.hibernate.ddl-auto=create
- Once the DB is created in the initial run, set the value
spring.jpa.hibernate.ddl-auto=update
. This will pre-populate data. - Navigate to the project root directory and run the following command.
mvn spring-boot:run
This exposes a set of API Endpoints which deals with CRUD operations for stocs.
- Verify if the server is running. Navigate to
http://localhost:8080/api/stocks/hello
- This will return HTTP 200 status response with message body
Hello
Navigate to http://localhost:8080/swagger-ui.html
.
This will display the Swagger UI which utilizes Open API documentation to visualize API documentation.
- GET
/api/stocks/hello
Endpoints for checking server health
- DELETE
/api/stocks/{id}
Deletes and existing stock price
- GET
/api/stocks/{id}
Retrieves a specific stock
- GET
/api/stocks
Lists stocks with pagination
- PATCH
/api/stocks/{id}
Updates the price of an existing stock
- POST
/api/stocks
Creates a new stock