Skip to content

Stereotype @Profiles not merged [SPR-10812] #15438

Closed

Description

@spring-projects-issues

Emerson Farrugia opened SPR-10812 and commented

I created environment stereotype annotations @Production, @Staging, and @Development to easily control which environment a few beans are available in. These annotations in turn have @Profile("somestring") as a meta-annotation.

I've hit an issue where the same @Component might be available in multiple environments, but not all of them, e.g.

@Staging
@Production
@Service
public class SomeService { ...

The org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider only sees one of the @Profile meta-annotations, and I don't see an obvious pattern as to which it's picking.

Is it possible to compute the disjunction of all available profiles in this case? Profile negation might be fun.


Affects: 3.2.3

Issue Links:

Referenced from: commits aecf60d

Activity

  1. spring-projects-issues commented on Aug 9, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Indeed, at this point, we only expect one @Profile annotation or one custom annotation meta-annotated with @Profile... In case of multiple occurences of the latter, the behavior is essentially undefined.

    We have a few related considerations for 4.0 anyway, so I'll put this onto the list for 4.0 RC1 still.

    Juergen

  2. spring-projects-issues commented on Feb 11, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Jakub Kubrynski commented

    @juergen.hoeller Maybe this functionality could be controlled by @Profile attribute on last class in hierarchy? Like

    @Profile("schedule", mergeInheritedProfiles = true)

    That will allow us to inherit profiles from custom stereotypes.

  3. added
    type: enhancement
    in: core
    on Jan 11, 2019
  4. added this to the 4.0 M3 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions