Reputation: 711
I have a confusion regarding datasource autoconfiguration in Spring-boot. From what I have read, we have to specify the datasource properties in the form spring.datasource.*
. But my application code works fine if I supply property name in the form SPRING_DATASOURCE_*
. Is there any reason that I am missing, due to which it works? Please clarify.
Upvotes: 0
Views: 257
Reputation: 2078
Spring Boot has so-called Relaxed Binding https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config-relaxed-binding which allows you to define configuration in different ways:
The latter is often used when passed via environment variables.
Upvotes: 2
Reputation: 42541
I think You've come across a feature of spring boot called Relaxed Binding.
It allows using some "relaxed" rules for binding to ConfigurationProperties. So essentially both ways of definition have the same effect in your application.
Here you can find a link to the relevant chapter in the official documentation
Upvotes: 2