Keep local, test, and production settings separate without committing secrets.
The core idea
Spring profiles let an application load environment-specific configuration. Externalized settings allow the same build to run in different environments with different endpoints, logging levels, and credentials.
A practical way to approach it
Keep safe defaults in configuration files, create clearly named profiles, and provide secrets through environment variables or a secret manager. Validate required configuration at startup and document the variables the application expects.
Try it in a small project
Create local and test profiles with different database URLs. Run an integration test using the test profile and confirm that a production credential is never present in the repository.
Common mistakes to avoid
Do not commit API keys or passwords into application.properties. Avoid duplicating entire configuration files when a few overrides are enough.
Key takeaway
Keep the first version small, make your assumptions explicit, and verify the result with a repeatable test. For production use, check the current official documentation for the tools and versions you choose.