Description
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:
- spring-sample.zip (150.45 kB)
Issue Links:
- Loading @Import(ChildConfig) or EnclosingConfig.ChildConfig and then ChildConfig does not load beans on ParentConfig [SPR-10546] #15176 Loading
@Import
(ChildConfig) or EnclosingConfig.ChildConfig and then ChildConfig does not load beans on ParentConfig - Allow the use of custom PropertySource annotations in @Configuration classes [SPR-8963] #13603 Allow the use of custom PropertySource annotations in
@Configuration
classes - Stereotype @Profiles not merged [SPR-10812] #15438 Stereotype
@Profiles
not merged
Referenced from: commits 5eecb13
4 votes, 8 watchers