Skip to content

Spring 3.5.0 app doesnt start sometimes (@ConditionalOnMissingBean not considered) #45938

Open
@Nico-Strecker

Description

@Nico-Strecker

Hey, I have a similar problem with Springdoc and Resilience4j, @wilkinsona as #45709.

Springdoc:

@Bean
@Lazy(false)
SpringDocParameterNameDiscoverer localSpringDocParameterNameDiscoverer() {
    return new SpringDocParameterNameDiscoverer();
}

Resilience4j:

@Bean
@ConditionalOnMissingBean
public ParameterNameDiscoverer parameterNameDiscoverer() {
    return configuration.parameterNameDiscoverer();
}

The app deploys fine as a -in-development version in our development environment on cloud foundry.
However, when pushing the same code to our release branch (only the version number in the pom.xml is changed — no -SNAPSHOT), the application fails with the following exception:

APPLICATION FAILED TO START
Description:

Parameter 1 of method spelResolver in io.github.resilience4j.springboot3.spelresolver.autoconfigure.SpelResolverConfigurationOnMissingBean required a single bean, but 2 were found:
- parameterNameDiscoverer: defined by method 'parameterNameDiscoverer' in class path resource [io/github/resilience4j/springboot3/spelresolver/autoconfigure/SpelResolverConfigurationOnMissingBean.class]
- localSpringDocParameterNameDiscoverer: defined by method 'localSpringDocParameterNameDiscoverer' in class path resource [org/springdoc/core/configuration/SpringDocConfiguration.class]
I would have expected that @ConditionalOnMissingBean is evaluated after all other beans are registered, so that parameterNameDiscoverer() from Resilience4j is only created if no other ParameterNameDiscoverer exists.
However, what seems to happen is that both beans are created.

Is there something I'm misunderstanding?
This was never an issue in Spring Boot 3.4.6, but in 3.5.0 the behavior seems to have changed and my code is now unstable.

I can't directly control either library and will raise issues if needed for them, but in my opinion, they work together correctly.
I just want to clarify this behavior first, might it be a spring boot 3.5.0 issue?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions