Skip to content
Veltoryx Technologies
ProLesson 5.3Intermediate2 min readUpdated 31 October 2026

Spring Profiles and Multi-Environment Deployment

Segregate environment configurations and beans cleanly across local dev, testing, and production using Spring Profiles.

01The environment dilemma

In software development, your code runs in vastly different environments throughout its lifecycle:

  • Local Machine (dev): Fast in-memory database (H2), verbose debug logging, fake mock payment gateway.
  • Staging / QA (stage): Shared testing database, sandbox API keys, realistic volume testing.
  • Production (prod): High-availability PostgreSQL cluster, strict audit logging, real credit card processing.

You must never use if (env.equals("prod")) statements scattered throughout your code.

Spring provides Profiles as an elegant architectural mechanism to map configurations and beans to specific target environments.

Spring Profiles Matrix
Fig. 1 · Spring Profiles Matrix

Loading the rest of the lesson…