Skip to content

Brest-Java-Course-2021-2/Vladimir-Petranovski-MD-SpringBoot

Repository files navigation

Java CI with Maven

Brest Java Course 2021 2

Vladimir-Petranovski-MD-SpringBoot

Developed by Uladzimir Petranouski

This is sample 'Motor depot' web application.

Project Information

Technology Stack

Requirements

  • JDK 11+
  • Git 2.25.1+
  • Apache Maven 3.6.3+

Build application:

$ git clone https://github.com/Brest-Java-Course-2021-2/Vladimir-Petranovski-MD-SpringBoot
$ cd Vladimir-Petranovski-MD-SpringBoot
Run for production:
$ mvn clean install -Dspring.profiles.active=prod
Run for testing:
$ mvn clean install -Dspring.profiles.active=test
Run for developing:
$ mvn clean install -Dspring.profiles.active=dev

Run tests:

$ mvn clean test

Run integration tests:

$ mvn clean verify

Rest server

Start Rest

Rest app configure

Setup rest-app in application.properties:

Profile Description
dev Run application with PostgresSQL database
test Run application with embedded H2 database in memory
prod Run application with MySQL database

Example:

spring.profiles.active=dev

In the root directory of the project:

$ java -jar -Dspring.profiles.active=dev rest-app/target/rest-app-1.0-SNAPSHOT.jar

Run in Postman

Swagger

The rest application will be accessible at http://localhost:8088. The swagger ui will be accessible at http://localhost:8088.

Web

Start Web

Run local tests (H2 in memory)

In the root directory of the project:

$ java -jar -Dspring.profiles.active=dev web-app/target/web-app-1.0-SNAPSHOT.jar

The web application will be accessible at http://localhost:8080.

Available REST endpoints

version

$ curl --request GET 'http://localhost:8088/version'

drivers_dto

$ curl --request GET 'http://localhost:8088/drivers_dto'

Pretty print json:

$ curl --request GET 'http://localhost:8088/drivers_dto' | json_pp

drivers

findAll

$ curl --request GET 'http://localhost:8088/drivers' | json_pp

findById

$ curl --request GET 'http://localhost:8088/drivers/1' | json_pp

create

$ curl --request POST 'http://localhost:8088/drivers' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
"driverName": "TOLIA",
"driverDateStartWork": 1214677490.532700000,
"driverSalary": 980
}'

update

$ curl --request PATCH 'http://localhost:8088/drivers/3' \
--header 'Content-Type: application/json' \
--data-raw '{
"driverName": "SERGEI",
"driverDateStartWork": 1014677990.532700000,
"driverSalary": 470
}'

delete

$ curl --request DELETE 'http://localhost:8088/drivers/3'

cars

findAll

$ curl --request GET 'http://localhost:8088/cars' | json_pp

findById

$ curl --request GET 'http://localhost:8088/cars/1' | json_pp

create

$ curl --request POST 'http://localhost:8088/cars' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
"carModel": "GIGULI",
"driverId": 2
}'

update

$ curl --request PATCH 'http://localhost:8088/cars/3' \
--header 'Content-Type: application/json' \
--data-raw '{
"carModel": "AUDI",
"driverId": 1
}'

delete

$ curl --request DELETE 'http://localhost:8088/cars/3'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published