Configuration and Environment Management

Separate code from environment-specific configuration. Configuration can come from environment variables, mounted files, secret stores, or deployment configuration.

String port = System.getenv().getOrDefault("PORT", "8080");
int httpPort = Integer.parseInt(port);

Validate configuration during startup so failures happen early. Never print credentials or tokens while diagnosing configuration.

Key Takeaways
  • Validate configuration at startup.
  • Keep secrets separate from ordinary configuration.
  • Never log sensitive configuration values.