Bootstrap application for testing a rest API, Codetest 2
gradle wrapper
./gradlew build
./gradlew build bootRun
or run fat jar
java -jar build/libs/radar-rest-service-0.1.0.jar
From the project root folder exec the commands to create a docker image and run it:
for macosx start the docker daemon
killall Docker && open /Applications/Docker.app
then execute the next commands in order to create the docker image and run it:
docker build -f docker/Dockerfile . -t radar
docker run -p 8888:8888 radar
to stop the application first we have to stop the docker process and then kill the docker process:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
to clean the docker images from the system:
docker images
docker rmi PID
Once you have the dockerized app is really easy bring it to the cloud. You look for a cloud provider to deploy it and host it.
You can see the swagger documentation in the following url:
curl -X GET -i "http://localhost:8888" -H "Content-type: application/json" -H "Accept: application/json"
curl -X POST -i "http://localhost:8888/radar" -H "Content-type: application/json" -H "Accept: application/json" -d '{"protocols":["avoid-mech"],"scans":[{"coordinates":{"x":0,"y":40},"enemies":{"type":"soldier","number":10}}]}'
curl localhost:8888/actuator/health
curl localhost:8888/actuator/info
curl localhost:8888/actuator/shutdown
ps -aux | grep "radar-rest-service-0.1.0.jar"
kill -9 $(jps | grep -i "radar-rest-service-0.1.0.jar" | awk '{print $1}')
sudo lsof -i :8888
sudo kill -9 PID
sdk install springboot
File | Project Structure | Project Settings | Modules | Paths tab | Compiler output Select 'use module compile output path' and add the build main and test folders
preferences | navigation bar toolbar click + button add the left and right arrows from the navigation list
preferences | editor | general | auto imports marks the checks with 'unambiguos' labels
- http://spring.io/guides
- https://spring.io/guides/gs/gradle/
- https://spring.io/guides/gs/actuator-service/
First of all, you can generate the scaffolding of this project using the INITIALIZR tool: https://start.spring.io/