When a BeanDefinitionRegistryPostProcessor bean is depends on a properties bean, the properties bean will not load the properties from application.yml
See original GitHub issueapplication.ym
:
the SeataAutoDataSourceProxyCreator
:
instantiate SeataAutoDataSourceProxyCreator
:
Is this a bug? I think the environment has been loaded. It can provide the properties.
springboot: 2.5.14 or 2.7.6 is tested.
When I remove the BeanDefinitionRegistryPostProcessor
from the implements, it will load properties normally.
Issue Analytics
- State:
- Created 9 months ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Creating Unknown Number of Beans With Configuration From ...
a BeanFactoryPostProcessor or a BeanDefinitionRegistryPostProcessor . However, here I don't have access to the properties-file or the RssConfig ...
Read more >24. Externalized Configuration - Spring
Spring Framework provides two convenient classes that can be used to load YAML documents. The YamlPropertiesFactoryBean will load YAML as Properties and the ......
Read more >Spring — Dynamically register beans in 4 ways At Run-Time
It allows specifying the bean class, bean characteristics plus constructor argument values and property values. 4. Dynamically register beans.
Read more >How To Instantiatiate Multiple Beans Dinamically in Spring ...
TL;DR. In this mini-HowTo I will show a way, how to instantiate multiple beans dinamically in Spring-Boot, depending on configuration-properties ...
Read more >Spring Boot Dynamic Bean Creation From Properties File ...
You can inject all properties as described below (not sure how to do it with your current properties structure, spring allows really anvanced...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@bclozel I tested, the
EnvironmentPostProcessor
is loaded first.@wangliang181230 I think @kse-music is right,
BeanDefinitionRegistryPostProcessor
is applied on bean definitions, way before any instantiation occurs. You cannot rely on properties beans being resolved and created at this phase of the application context. You can always bind directly from the environment, but note that chances are thatEnvironmentPostProcessor
were not applied at this stage so you might get the wrong property value. I’d suggest revisiting this contract with the context lifecycle in mind.