Raise log level to warn when enhancement cannot apply

Closes gh-31102
This commit is contained in:
Juergen Hoeller
2023-09-03 00:42:38 +02:00
parent 23a0903b5c
commit d6e167d16e

View File

@@ -506,11 +506,12 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
throw new BeanDefinitionStoreException("Cannot enhance @Configuration bean definition '" +
beanName + "' since it is not stored in an AbstractBeanDefinition subclass");
}
else if (logger.isInfoEnabled() && beanFactory.containsSingleton(beanName)) {
logger.info("Cannot enhance @Configuration bean definition '" + beanName +
else if (logger.isWarnEnabled() && beanFactory.containsSingleton(beanName)) {
logger.warn("Cannot enhance @Configuration bean definition '" + beanName +
"' since its singleton instance has been created too early. The typical cause " +
"is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor " +
"return type: Consider declaring such methods as 'static'.");
"return type: Consider declaring such methods as 'static' and/or mark the " +
"containing configuration class as 'proxyBeanMethods=false'.");
}
configBeanDefs.put(beanName, abd);
}