This is a simple Spring Boot application example. Its most key features:
- two REST endpoints
- GET actions
- POST action
- DB usage
- dockerized deployment
- even some tests
- Set up DB & connection details in
application.properties- in case of DB from docker compose -
spring.datasource.url=jdbc:mysql://localhost:3307/db?autoReconnect=true
- in case of DB from docker compose -
- Run Application
- Assemble project
- In terminal perform
./gradlew assemble(you may need to specifyorg.gradle.java.homeingradle.properties; see this) - or use Gradle tool window from IntelliJ (
app/Tasks/build/assemble)
- In terminal perform
- Run the following:
docker build -t app
docker-compose up -dNote that the application container may fail a few times before a successful start. This is because it tries to connect the DB before the DB is able to accept a connection.
The app in both cases (non-dockerized and dockerized runs) can be accessed at http://localhost:8080.
There are three REST endpoints:
0. GET /api/health
POST /api/actionallowing the addition of action objectsGET /api/actionsthat gives all the actions from DB
See sample_requests directory for examples.