Skip to content

Custom @Profile annotations not working on @Configuration classes [SPR-11808] #16428

Closed
@spring-projects-issues

Description

@spring-projects-issues

Miguel A. Baldi Hörlle opened SPR-11808 and commented

Starting at version v3.2.2, custom @Profile annotations no longer work on @Configuration classes.

@Profile("main")
public @interface Main {
}
@Configuration
@ComponentScan(basePackageClasses = MainConfiguration.class)
@Main
public class MainConfiguration {
}

Before version 3.2.3, the above configuration works as expected, MainConfiguration only gets executed when profile "main" is activated.

Unfortunately, when I upgraded to version 3.2.8, whenever I have a custom profile annotation on a @Configuration class, the active profiles are not honored.

I've searched the documentation looking for some light on this, but with no luck.
Is this the expected behavior or a bug?
I've attached a sample application to demonstrate this behavior.

mvn install

Will use version 3.2.2, and all tests must pass.

mvn -Pbug install

will use version 3.2.8, and tests shall fail.

I think I found the commits that changed this behavior, they are related to issue #15176. When I revert the commits related to that issue, everything works for me.

I have a large enterprise application that relies on that feature (custom @Profiles) and we need to upgrade Spring because of issues #15018 and #15726.
Thanks!


Affects: 3.2.3, 3.2.8

Attachments:

Issue Links:

Referenced from: commits 5eecb13

4 votes, 8 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions