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.

@ConfigurationProperties should have an option to have properties read each time from Environment

See original GitHub issue

Originally raised on the SPR issue tracker: https://jira.springsource.org/browse/SPR-11289

@ConfigurationProperties objects should have some mechanism for allowing some or all properties to be read from a propertySource on each get invocation. It seems like instead of injected a concrete implementation into the AppContext we should inject a proxy for the Config object which can reference the Environment abstraction.

The usecase for this would be when we have implemented a custom PropertySource which is aware of property changes.

Issue Analytics

  • State:open
  • Created 10 years ago
  • Reactions:1
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
dsyercommented, Jan 26, 2022

FYI spring-cloud-config isn’t needed for @RefreshScope, and also @RefreshScope is not needed for @ConfigurationProperties. Just put spring-cloud-commons on the classpath - it’s very lightweight, really - the only dependency is Spring Boot.

1reaction
Code2Lifecommented, Jan 24, 2022

Hi @philwebb @dsyer @wilkinsona,

I think the original feature this issue requests have been implemented in my project: https://github.com/Code2Life/spring-boot-dynamic-config

Adding @DynamicConfig on @ConfigurationProperties simply works !

With Spring Boot native features leveraged, and with the file watcher and hot-reload mechanism implemented by only 400+ lines of code, @Value @ConfigurationProperties could always be the newest value.

This lib is widely used in 20+ core applications for more than half a year in the company I’m working for. Hope this feature becomes a built-in feature of Spring Boot. @philwebb @dsyer @wilkinsona Would you like to take a look at the source codes and put some suggestions? Thanks !

Read more comments on GitHub >

github_iconTop Results From Across the Web

24. Externalized Configuration - Spring
Spring Boot lets you externalize your configuration so that you can work with the same application code in different environments. You can use...
Read more >
Guide to @ConfigurationProperties in Spring Boot - Baeldung
A quick and practical guide to @ConfigurationProperties annotation in Spring Boot.
Read more >
Configuring a Spring Boot Module with ... - Reflectoring
Using @ConfigurationProperties to Configure a Module · The prefix defines which external properties will be bound to the fields of the class.
Read more >
Spring Boot @ConfigurationProperties example - Mkyong.com
Spring Boot @ConfigurationProperties is letting developer maps the entire .properties and yml file into an object easily. P.S Tested with ...
Read more >
Spring Boot Configuration Properties
Introduction · 1. application.properties File. · 2. Setting up Application · 3. Property Injection Using @Value Annotation · 4. Using @ ...
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