question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When a BeanDefinitionRegistryPostProcessor bean is depends on a properties bean, the properties bean will not load the properties from application.yml

See original GitHub issue

application.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:closed
  • Created 9 months ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
wangliang181230commented, Dec 9, 2022

but note that chances are that EnvironmentPostProcessor were not applied at this stage so you might get the wrong property value.

@bclozel I tested, the EnvironmentPostProcessor is loaded first.

1reaction
bclozelcommented, Dec 9, 2022

@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 that EnvironmentPostProcessor 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found