New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support null values when binding properties #24133
Comments
Spring Boot does not support the reloading of properties at runtime. You may be interested in Spring Cloud's support for changing the environment and its refresh scope. |
I am sorry not make myself clear.My project is indeed a spring cloud application, The Properties bean is also annotated by @RefreshScope.While The config server is alibaba‘s nacos. When I change the external config file as above(set the value to null), the properties's value didn't change as expect. In debug mode, when the external config file changed from test:
users:
- Andy to test:
users: I can find that the propertySource in Environment#propertySources#propertySourceList changed to Then I dig into the source of
private ConfigurationProperty find(PropertyMapping mapping) {
String propertySourceName = mapping.getPropertySourceName();
Object value = getPropertySource().getProperty(propertySourceName);
if (value == null) {
return null;
}
...
} when the value is null, the method is return null, which means no such item. while in my situation,set
@wilkinsona,I'm appreciate that you could take a look at this problem again. |
See spring-projects/spring-framework#25142 for background on |
This is a limitation of the way that |
#28139 describes another use case for being able to clear the value of a property somehow. |
@philwebb do you know what all is needed to get this fixed? If spring-projects/spring-framework#19986 is addressed, would it be easy for spring-boot to support nulls? Trying to see how to move this forward. |
It's not just spring-projects/spring-framework#19986. Spring Framework's |
Application has a ben annotated with
@ConfigurationProperties("test")
that has aList<String>
attribute calledusers
. at the beginning, one item listed in the external configuration fileas the application is running, change the configuration file to the following
or
what I expect is
users=null
orusers =[]
, while the result is stillusers[0]=Andy
it‘s ok for the following pattern :
Here's a test that fails with Spring Boot
2.1.17.RELEASE
The text was updated successfully, but these errors were encountered: