Important
|
This code repository is used as an example project for the training "Docker for JVM projects". It’s not intended for real-world use. |
A RESTful web service to managing ToDo items. ToDo items are stored in a database. The underlying implementation is based on Spring Boot built by Maven or Gradle.
Execute the goal bootRun
with the Maven Wrapper command to bring up the service. Optional arguments can be provided e.g. the server port. The following example starts the application on port 9090.
$ ./mvnw spring-boot:run -Dspring-boot.run.jvmArguments="-Dserver.port=9090"
You can activate a profile by passing in the relevant environment. At the moment only prod
is supported. The default profile uses a H2 database.
The following example uses the production profile.
$ ./mvnw spring-boot:run -Dspring-boot.run.profiles=prod
Execute the task bootRun
with the Gradle Wrapper command to bring up the service. Optional arguments can be provided e.g. the server port. The following example starts the application on port 9090.
$ ./gradlew bootRun --args='--server.port=9090'
You can activate a profile by passing in the relevant environment. At the moment only prod
is supported. The default profile uses a H2 database.
The following example uses the production profile.
$ ./gradlew bootRun --args='--spring.profiles.active=prod'
Once the service is up and running, you can call the exposed CRUD endpoints.
Example command:
$ curl -X GET localhost:8080/todos
Example response:
[ { "id":1, "name":"Buy milk", "completed":false }, { "id":2, "name":"Pay bills", "completed":true } ]
Example command:
$ curl -X GET localhost:8080/todos/2
Example response:
{ "id":2, "name":"Pay bills", "completed":true }
Example command:
$ curl -X POST -H "Content-Type:application/json" -d '{ "name" : "Buy milk", "completed" : false }' localhost:8080/todos