Minimal skeleton for an IT asset management service.
Database schema is managed only by Flyway migrations.
- Java 21+, Spring Boot
- PostgreSQL + Flyway (
src/main/resources/db/migration) - Gradle Wrapper
- Base package:
net.psv73.assetregistry
- ✅ Preserved: migrations, configuration, entry point
- 🔜 To be implemented: domain, repositories, web layer
src/
├─ main/
│ ├─ java/net/psv73/assetregistry/
│ │ ├─ AssetRegistryApplication.java
│ │ ├─ config/ (.gitkeep)
│ │ ├─ entity/ (.gitkeep)
│ │ ├─ repository/ (.gitkeep)
│ │ └─ web/ (.gitkeep + dto/request/response)
│ └─ resources/
│ ├─ application.yml
│ ├─ application.properties
│ ├─ application-local.yml
│ └─ db/migration/
│ ├─ V1__init.sql
│ ├─ V2__seed_reference_data.sql
│ └─ V3__demo_data.sql
└─ test/java/net/psv73/assetregistry/.gitkeep
Note about configuration: keep one main source of truth. Recommended:
application.yml— defaultapplication-local.yml— local profile- remove
application.propertieslater if not needed
- JDK 21+
- PostgreSQL 14+ (or Docker)
docker run --name asset-registry-pg -p 5432:5432 -e POSTGRES_USER=asset -e POSTGRES_PASSWORD=asset -e POSTGRES_DB=asset_registry -d postgres:15src/main/resources/application.yml
spring:
datasource:
url: jdbc:postgresql://localhost:5432/asset_registry
username: asset
password: asset
jpa:
hibernate:
ddl-auto: validate
open-in-view: false
properties:
hibernate.format_sql: true
hibernate.jdbc.time_zone: UTC
flyway:
enabled: true
locations: classpath:db/migration
baseline-on-migrate: true
server:
port: 8080
logging:
level:
root: INFOsrc/main/resources/application-local.yml (optional for local dev)
spring:
datasource:
url: jdbc:postgresql://localhost:5432/asset_registry
username: asset
password: asset
logging:
level:
org.hibernate.SQL: INFO./gradlew clean build
./gradlew bootRungradlew.bat clean build
gradlew.bat bootRunRun with local profile:
./gradlew bootRun --args='--spring.profiles.active=local'- Scripts:
V{number}__{description}.sql - Automatically applied on startup
ddl-auto: validate— schema is changed only via migrations
Currently no public controllers. The app should start without errors and apply V1..V3.
Check by startup logs or directly in DB (\dt / list tables).
- Decide on configuration format (YAML preferred), remove
application.propertiesif redundant. - Add a simple health endpoint (via Spring Actuator or
HealthController). - Start with a reference entity (e.g.,
DeviceType): entity → repository → GET controller. - Add tests (integration with Testcontainers, unit with H2/Mockito).
- Set up CI (Gradle build + tests) and push to GitHub.
The repository contains a ready-to-use Docker Compose setup for a local PostgreSQL instance.
- Files:
docs/docker-compose.yml,docs/db-init/01-init-asset.sql - Initialization: creates the
assetrole, grants ownership and privileges on theasset_registrydatabase.
Start the DB:
docker compose -f docs/docker-compose.yml up -dCheck status:
docker compose -f docs/docker-compose.yml psStop:
docker compose -f docs/docker-compose.yml downTroubleshooting:
- If port 5432 is occupied, either stop the process using it or change the mapped port in
docker-compose.yml(e.g.,15432:5432), then update yourspring.datasource.urlaccordingly. - To reset the database completely (fresh start), run:
docker compose -f docs/docker-compose.yml down -v docker compose -f docs/docker-compose.yml up -d