Skip to content

Review Default Profile section in the reference documentation #30319

Closed
@manueljordan

Description

@manueljordan

In the current reference documentation exists the Default Profile section. It has the following content

Starting with a code:

@Configuration
@Profile("default")
public class DefaultDataConfig {

    @Bean
    public DataSource dataSource() {
        return new EmbeddedDatabaseBuilder()
            .setType(EmbeddedDatabaseType.HSQL)
            .addScript("classpath:com/bank/config/sql/schema.sql")
            .build();
    }
}

and the following content/explanation:

If no profile is active, the dataSource is created. You can see this as a way to provide a default definition for one or more beans.
If any profile is enabled, the default profile does not apply.

You can change the name of the default profile by using setDefaultProfiles() on the Environment or,
declaratively, by using the spring.profiles.default property.

Therefore: Why from the beginning was not used directly spring.profiles.active? - it especially taking in consideration that is known that spring.profiles.active has more precedence and overrides by complete spring.profiles.default as indicated in bold above.

As summary:

  • Why does spring.profiles.default exist if the same approach can be accomplished through spring.profiles.active?

Is not clear when is mandatory use the former over the latter - and taking the special consideration about the behavior of overriding if the latter is declared.

Just in case, the @Profile javadoc does not contain some indication about this

I create a post on SO at:

But I think the explanation from the source (here) should be expanded. Thanks for your understanding

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions