SPRING CONCEPTS

Profiles

Spring Concepts / Profiles

Profiles select which conditional bean definitions participate in a context.

Understand the idea

Activate dev or prod before context refresh. A matching Profile condition registers its component, configuration or bean factory method. This lesson deliberately selects one catalog-source implementation. Activating none can leave a missing dependency; activating both can make a single-valued dependency ambiguous.

A concrete example

@Bean @Profile("dev")
CatalogSource source() { return () -> "Sample products"; }

In the application

See the independently runnable examples in Stage 26.

A profile selects configuration; it is not an authorization boundary.

See it in a working stage

Related concepts

Read the official documentation ↗
Java 21 · Spring Boot 4.1.1 · Edupoly