spring-boot: Log unknown properties when using @ConfigurationProperties
Enhancement
With YAML properties it’s too easy to corrupt properties, by just adding whitespace. eg:
# incorrect
spring:
cloud:
stream:
input:
consumer:
maxAttempts: 5
group: api
# correct
spring:
cloud:
stream:
input:
consumer:
maxAttempts: 5
group: api
If would be great if regardless the ignoreUnknownFields
property, Spring Boot could load a WARN
that unmatched property was found. I think that will preserve many stupid mistakes people are making. I can possibly do a PR if you agree it should be implemented.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (16 by maintainers)
Yes. Thank you.
Of course, it’s better to have such properties included in the metadata than not. However please keep in mind, that a lot of production systems keep properties in the separate repository than the application source code. The IDE plugin doesn’t use metadata in non-java projects so it can be used only during development. Often even the operation teams manage those properties directly, using vi instead of the Intellij. So the very first moment to verify the properties is during the application startup - in such case the sooner the better. In my opinion, WARN is adequate to seriousness of the situation, but of course if I must choose between DEBUG and nothing I prefer DEBUG.
I’ve checked our applications and currently, there are no invalid properties. We include over 15 different Spring Boot & Spring Cloud starters. However, the problem I found is that after adding unknown property it’s logged 3 times: