Spring Rest API with MySQL sample to create, update, list and remove records using some bdd approaches
Follow the instructions bellow to run th project localy.
You will need the JDK 11 installed to compile the project. You will need the Apache maven Version 3.5.4 installed to compile the project
This is a Spring Boot Maven RestFul API whitch uses MySQL database to store the worstest movies winners for Golden Raspberry Awards
To change the initial Data Source replace the src/main/resources/initialdatasource.csv
file content
docker-compose up -d
Docker will create two images linked by the network "logon-compose-network"
-
my-sql
image link your computer port 3306 to docker port 3306 under network "logon-compose-network" ana mantains your volume (see docker compose file) -
mysql-workbench
image link your computer port 3000 to docker port 3000 under network "logon-compose-network"
To access MySQL Workbench throw your browser acess http://localhost:3000
Inside MySQL Workbench create a new connection to your MySQL database by de following steps:
- Create a connection to MySQL using the host
my-sql
(host name inside "logon-compose-network") - Set 'logon' as database name
- Set 'logon' as user name
- Set 'logon' as password
mvn spring-boot:run
jdbc url = jdbc:h2:mem:testdb
user name = sa
password = password
Thi api is on staging enviroment, after 30 minutes of inactivitie it stand by
curl --location --request GET 'http://localhost:8080/api/fornecedores'
curl --location --request GET 'http://localhost:8080/api/fornecedores/1'
curl --location --request PUT 'http://localhost:8080/api/fornecedores/1' \
--header 'Content-Type: application/json' \
--data-raw '{
"nome":"jaaziel"
}'
curl --location --request POST 'http://localhost:8080/api/fornecedores' \
--header 'Content-Type: application/json' \
--data-raw '{
"nome":"joal",
"cnpj":"123456789"
}'