Scrivio Interview library
DebuggingIntermediate6 min read · updated 12 November 2026

An auto-configured bean you expected is missing, or your own bean is ignored. How do you find out which conditions matched?

Start the application with --debug, or set debug=true, to print the condition evaluation report; the actuator conditions endpoint shows the same information on a running application. The report lists positive and negative matches, each with the reason. From there we check whether our own bean was defined before the auto-configuration evaluated @ConditionalOnMissingBean, and whether the property names and the classpath are what the conditions expect.

Why this question is asked

Auto-configuration saves a lot of code until it does something unexpected: a DataSource is missing, our custom ObjectMapper is ignored, or two beans of the same type appear. Guessing at the cause wastes hours, while Spring Boot can tell us exactly which conditions matched and why. Interviewers ask this to see whether we know those tools and how to read them. In this answer, we will recap how auto-configuration decides, produce and read the condition evaluation report, use the actuator endpoint, and then go through the three usual causes: bean ordering, property names and the classpath.

1A Quick Recap of How Auto-Configuration Decides

An auto-configuration is a configuration class that Spring Boot loads from the AutoConfiguration.imports files of the jars on the classpath. Almost every auto-configuration and many of its @Bean methods carry conditions, such as @ConditionalOnClass, @ConditionalOnProperty or @ConditionalOnMissingBean. Spring Boot evaluates these conditions while it registers bean definitions, and it records the outcome of every evaluation, including the reason, in an object called the ConditionEvaluationReport. Our tools simply show that record.

2Printing the Condition Evaluation Report

The quickest way to see the report is to start the application with debug mode enabled, either as a command-line argument or as a property. This turns on debug logging for a selection of core loggers and prints the report at startup.

Shell
$ java -jar shop.jar --debug
# or in application.yml: debug: true
============================
CONDITIONS EVALUATION REPORT
============================
Positive matches:
-----------------
JacksonAutoConfiguration matched:
- @ConditionalOnClass found required class 'com.fasterxml.jackson.databind.ObjectMapper' (OnClassCondition)
Negative matches:
-----------------
DataSourceAutoConfiguration:
Did not match:
- @ConditionalOnClass did not find required class 'org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType' (OnClassCondition)
JacksonAutoConfiguration.JacksonObjectMapperConfiguration#jacksonObjectMapper:
Did not match:
- @ConditionalOnMissingBean (types: ObjectMapper; SearchStrategy: all) found beans of type
'ObjectMapper' customObjectMapper (OnBeanCondition)
Exclusions:
-----------
None
Unconditional classes:
----------------------
...

The output above is shortened and its exact wording varies between versions, but its structure is stable. Positive matches are auto-configurations and bean methods whose conditions all passed. Negative matches are those that were skipped, with the condition that failed and why: a class not found, a property with the wrong value, or a bean that already existed. Exclusions lists auto-configurations removed with exclude, and Unconditional classes those without class-level conditions.

If the application fails to start, Spring Boot usually prints a hint suggesting re-running with debug enabled to display the report, which is a reminder that this is the first tool to reach for. Searching the output for the name of the missing bean type or the auto-configuration is usually enough to find the relevant entry.

3The Actuator Conditions Endpoint

In an environment where restarting with --debug is not practical, the actuator conditions endpoint returns the same report as JSON from the running application. It must be exposed explicitly with management.endpoints.web.exposure.include, and like any actuator endpoint that reveals internals it should be secured.

Java
GET /actuator/conditions
{
"contexts": {
"shop": {
"positiveMatches": { "JacksonAutoConfiguration": [ { "condition": "OnClassCondition", "message": "..." } ] },
"negativeMatches": { "DataSourceAutoConfiguration": { "notMatched": [ { "condition": "OnClassCondition", "message": "..." } ] } },
"unconditionalClasses": [ ... ]
}
}
}

4Cause 1: Your Bean and @ConditionalOnMissingBean

When Boot's bean is present and ours is ignored, or both exist, the issue is usually how our bean relates to the auto-configuration's @ConditionalOnMissingBean. The condition looks for bean definitions of a type, registered before the auto-configuration is processed. User configuration found by component scanning is always processed first, so a bean there is seen. But a bean defined in a class that is itself loaded late, for example another auto-configuration without proper ordering, may be registered too late.

Type matters as much as timing. The condition matches on the declared type of the bean definition, which for a @Bean method is its return type. If our method returns Object or a narrow interface, the condition may not see an ObjectMapper and Boot adds its own. And some auto-configurations back off on a different type than we expect, for example a builder or a customizer rather than the main object, so the report's message, which names the types it searched for, is the thing to read.

Java
@Bean
Object customObjectMapper() { return new ObjectMapper(); } // condition may not see an ObjectMapper
@Bean
ObjectMapper customObjectMapper() { return new ObjectMapper(); } // Boot's mapper backs off
Step throughFinding out why a bean is missing or ignored
  1. Run with --debug or call /actuator/conditions
  2. Is the auto-configuration in positive matches?
    YesLook at its bean methods' conditionsNoRead the failing condition's reason
  3. Reason: class not found?
    YesAdd the dependency, check versionsNoCheck the next reason
  4. Reason: property value?
    YesFix the property name or valueNoCheck bean types and order

4 steps in order. Play them, or step through them one at a time.

5Causes 2 and 3: Property Names and the Classpath

Property conditions fail quietly when the name is slightly wrong. @ConditionalOnProperty(prefix = "spring.kafka", name = "enabled") will not see spring.kafka.enable, and an environment variable that maps to a different name never matches. The report says which property it looked for and what it found, so we compare that name character by character with the configuration, and use the actuator env endpoint to confirm the effective value.

Classpath conditions fail when a dependency is missing, has the wrong scope, or brings a different version than the auto-configuration expects. A test-scoped dependency is invisible at runtime; an exclusion in the build removes a transitive jar; a library version without the class the condition checks for fails the condition. Running mvn dependency:tree or gradle dependencies, and checking the report's class name, settles it.

Finally, check exclusions: spring.autoconfigure.exclude or exclude on @SpringBootApplication removes an auto-configuration entirely, and it appears in the Exclusions section rather than under negative matches, which is easy to overlook.

6Follow-up questions

Can I get the report in a test?

Yes. ApplicationContextRunner can print it for a failing case, and in a @SpringBootTest we can inject ConditionEvaluationReport via ConditionEvaluationReport.get(beanFactory) or simply set debug=true in the test properties. Spring Boot's ConditionEvaluationReportLoggingListener can also be used with a runner to log it.

Why is debug=true not the same as setting the root log level to DEBUG?

debug=true enables debug output for a selection of core loggers, such as the container and Hibernate, and prints the condition report. It does not turn the whole application to DEBUG. logging.level.root=debug does the latter and produces far more output.

What does SearchStrategy mean in the report?

It says where the bean condition looked: all searches the context and its ancestors, current only the current context, and ancestors only the parents. In applications with a parent context, such as some Spring Cloud setups, a bean in the parent may or may not count depending on this setting.

7Conclusion

In this answer, we debugged missing and ignored beans with Spring Boot's own record of its decisions. The condition evaluation report, printed with --debug or debug=true and available from the actuator conditions endpoint, lists positive and negative matches with reasons, plus exclusions. With it, we checked the usual causes: whether our bean was registered, with the right type, before the auto-configuration evaluated @ConditionalOnMissingBean, whether property names matched exactly, and whether the classpath held the expected classes.

What to say in the interviewAbout 80 seconds aloud

Open with

I would not guess; Spring Boot records every condition decision. First I start the application with --debug, or debug: true, which prints the conditions evaluation report at startup.

Then, if they want more

If restarting is not practical, the actuator conditions endpoint gives the same data as JSON, as long as it is exposed and secured. The report has positive matches, negative matches with the reason each condition failed, exclusions and unconditional classes. I search it for the auto-configuration or the bean type I care about.

If the reason is a class not found, I check the dependency tree for a missing jar, wrong scope or version. If it is a property, I compare the exact name the condition looked for with my configuration, and confirm the effective value with the env endpoint, because relaxed names and typos are common.

If my own bean is ignored or duplicated, I look at ConditionalOnMissingBean: it matches on registered bean definitions by type, so I make sure my bean is defined in normal user configuration, which is processed before auto-configurations, and that the Bean method returns the specific type, not Object or a narrow interface.

I also check the exclusions section, since an excluded auto-configuration does not appear under negative matches.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "An auto-configured bean you expected is missing, or your own bean is ignored. How do you...": https://scrivio-interview-library.netlify.app/spring-boot/spring-configuration/657034c75b/