Skip to content

ConditionalOnBean behaves weirdly when combined with ConditionalOnMissingBean #20855

@FrancoCorleone

Description

@FrancoCorleone

Hi all,
I had a following scenario which lead me to conclusion that there's a bug in how springboot handles those two annotations mentioned in the title.

  1. Let's have an interface A
  2. Let's create implementation B of interface A.
  3. Let's create a Bean of A (return B) and annotate it with ConditionalOnMissingBean (just a default bean implementation for when the user does not define his own implementation, kind of like a fallback)
  4. Let's create a RestController with annotation ConditionalOnBean(A)
  5. Endpoint is not instantiated which I believe it should

Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions