Configuration Files
The application uses a multi-profile configuration approach:application.yaml
Main configuration file with production defaults
application-local.yaml
Local development overrides with verbose logging
File Locations
src/main/resources/application.yaml- Main configurationsrc/main/resources/application-local.yaml- Local development profilesrc/main/resources/db/migration/- Flyway database migrations
Core Configuration
Application Properties
application.yaml
The active profile defaults to
local and can be overridden with the ENVIRONMENT environment variable.Database Configuration
DataSource Settings
The application uses PostgreSQL as its primary database:application.yaml
JPA and Hibernate
Production settings:application.yaml
application-local.yaml
Flyway Migrations
Flyway handles database schema versioning:application.yaml
src/main/resources/db/migration/ and follow the naming pattern V{version}__{description}.sql.
Environment Variables
The following environment variables can be used to override configuration:Required Variables
| Variable | Default | Description |
|---|---|---|
ENVIRONMENT | local | Active Spring profile (local, dev, prod) |
SPRING_DATASOURCE_URL | jdbc:postgresql://localhost:5432/user_db | Database JDBC URL |
SPRING_DATASOURCE_USERNAME | postgres | Database username |
SPRING_DATASOURCE_PASSWORD | password | Database password |
Example Usage
Actuator Configuration
Spring Boot Actuator provides health checks and monitoring endpoints:application.yaml
Available Endpoints
| Endpoint | URL | Description |
|---|---|---|
| Health Check | /actuator/health | Application health status |
| Info | /actuator/info | Application information |
OpenAPI Configuration
OpenAPI documentation is configured in thelocal profile:
application-local.yaml
Accessing Documentation
- Swagger UI: http://localhost:8080/swagger-ui/index.html
- OpenAPI JSON: http://localhost:8080/api-docs
OpenAPI documentation is enabled in the
local profile for development. Consider security implications before enabling in production.Profile-Specific Configuration
Local Profile
Activated automatically by default, provides:- Verbose SQL logging (
show-sql: true) - Formatted SQL output (
format_sql: true) - Database schema validation (
ddl-auto: validate) - Enabled Swagger UI
Production Profile
Optimized for production:- Minimal logging (
show-sql: false) - No schema generation (
ddl-auto: none) - Environment-specific database credentials
- Actuator endpoints for monitoring
Configuration Best Practices
Use Environment Variables for Secrets
Never hardcode credentials. Use environment variables for sensitive data:
Separate Profiles by Environment
Create profile-specific files for different environments:
application-local.yaml- Local developmentapplication-dev.yaml- Development serverapplication-prod.yaml- Production
Override with External Configuration
Place an
application.yaml outside the JAR for runtime overrides:Cloud Deployment Configuration
For Google Cloud Run deployment (as configured incloudbuild.yaml), secrets are managed via Secret Manager:
cloudbuild.yaml
Troubleshooting
Configuration not loading
Configuration not loading
Ensure the profile is active:Check the startup logs for:
Database connection errors
Database connection errors
Verify your database configuration:
- Check PostgreSQL is running:
pg_isready - Verify credentials in
application.yaml - Test connection:
psql -h localhost -U postgres -d user_db
Flyway migration failures
Flyway migration failures
If migrations fail:
- Check migration scripts in
src/main/resources/db/migration/ - Verify baseline:
spring.flyway.baseline-on-migrate=true - Check Flyway history:
SELECT * FROM flyway_schema_history;
Property not being overridden
Property not being overridden
Check the property precedence:
- Command line arguments (highest priority)
- Environment variables
- Profile-specific YAML files
- Default
application.yaml(lowest priority)
Next Steps
Docker Setup
Learn how to run the application in Docker
Testing
Understand the testing configuration
API Reference
Explore the API endpoints
Architecture
Learn about the system architecture