spring-projects / spring-projects/spring-framework
Print out configuration class import tree/order during application startup
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
Feature Description
Currently, users relies on --debug flag to diagnose complex Spring Boot configuration precedence, condition evaluations, and auto-configurations. It can print out positive and negative condition matches (e.g., @ConditionalOnClass, @ConditionalOnMissingBean) for auto-configuration classes. It explains why a configuration evaluated to true or false, but not which parent configuration or @Import chain pulled it into the context.
There is no native way to visualize the actual configuration class import tree (i.e., showing how @Configuration classes, @Import selectors, inner configurations, and auto-configurations trigger one another hierarchically) directly during application startup.
Adding an optional configuration tree logger would make debugging configuration precedence, custom starter ordering, and bean initialization issues significantly easier.
Motivation / Use Case
When building large modular applications or custom Spring Boot starters, developer issues often stem from:
- Understanding why a specific auto-configuration or nested configuration was pulled into the context.
- Tracking deep chains of
@Import/@ImportSelector/@ImportResourceannotations. - Verifying processing precedence among user configurations,
@AutoConfigureBefore, and@AutoConfigureAfter.
Proposed Implementation
Implementing this feature is straightforward, as a dedicated logger or tree printer can run during the BeanFactoryPostProcessor or ApplicationListener phase to provide instant visual insight into the configuration structure during startup without extra endpoint queries.
Sample code
@Configuration
public class ConfigurationLoggerConfig implements BeanFactoryPostProcessor {
private static final Logger log = LoggerFactory.getLogger(ConfigurationLoggerConfig.class);
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
String[] configBeans = beanFactory.getBeanNamesForAnnotation(Configuration.class);
log.info("=== Registered @Configuration Classes ===");
for (String name : configBeans) {
Object configClass = beanFactory.getBeanDefinition(name).getBeanClassName();
log.info("Config Bean: {} -> {}", name, configClass);
}
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the BeanFactoryPostProcessor and ApplicationListener startup entry points described in the issue, along with the ConfigurationLoggerConfig sample. Clarify how configuration classes, imports, selectors, resources, and ordering should be represented, then define tests or startup output that demonstrate the optional logger reports the complete import tree and order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100