A Java Spring Boot REST API with PostgreSQL, orchestrated by Aspire via Dockerfile.
- Backend: Java 21 + Spring Boot 3.4
- Database: PostgreSQL + pgAdmin
- AppHost: Standalone
AppHost.javawithaddDockerfile
cd samples/spring-boot-postgres
aspire runAddDockerfilefor Java applicationsAddPostgreswith pgAdmin- JDBC connection string injection via
NOTESDB_JDBCCONNECTIONSTRINGenv var - Multi-stage Docker build for Spring Boot
Once running, the API is available at the displayed endpoint:
GET /api/notes- List all notesPOST /api/notes- Create a note (JSON body:{"title": "...", "content": "..."})GET /api/notes/{id}- Get a specific noteDELETE /api/notes/{id}- Delete a note
Example using curl:
# Create a note
curl -X POST http://localhost:8080/api/notes \
-H "Content-Type: application/json" \
-d '{"title":"Hello","content":"My first note"}'
# List all notes
curl http://localhost:8080/api/notes
# Get a specific note
curl http://localhost:8080/api/notes/1
# Delete a note
curl -X DELETE http://localhost:8080/api/notes/1pgAdmin is automatically configured and accessible through the Aspire dashboard. Use the connection details provided in the dashboard to connect to the PostgreSQL instance.