Affects: 2.6.3 (and probably others)

The following application should start without any problems (imo), but it fails to start due to missing dependency of type SpringTestApplication$SomeInterface

@SpringBootApplication
public class SpringTestApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringTestApplication.class, args);
    }

    public interface SomeInterface {
    }

    @Component
    @Profile("SOME_PROFILE")
    public static class SomeInterfaceImpl implements SomeInterface {
    }

    @Component
    @ConditionalOnMissingBean(SomeInterface.class)
    public static class SomeInterfaceDefaultImpl implements SomeInterface {
    }

    @Component
    @RequiredArgsConstructor
    public static class SomeComponent {
        private final SomeInterface someInterface;
    }

}
2022-01-26 11:34:27.877 ERROR 19356 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of constructor in SpringTestApplication$SomeComponent required a bean of type 'SpringTestApplication$SomeInterface' that could not be found.


Action:

Consider defining a bean of type 'SpringTestApplication$SomeInterface' in your configuration.

However if I change @ConditionalOnMissingBean(SomeInterface.class) to @ConditionalOnMissingBean(type = "SomeInterface") it launches without any problems.

Comment From: bclozel

@sfilipiak-inpost @ConditionalOnMissingBean is only meant to be used in auto-configurations - the javadoc for this class says:

The condition can only match the bean definitions that have been processed by the application context so far and, as such, it is strongly recommended to use this condition on auto-configuration classes only. If a candidate bean may be created by another auto-configuration, make sure that the one using this condition runs after.

In this case, I'd consider that using such a condition within the same configuration class, outside of an auto-configuration is not supported.