[英]Spring Boot: Datasource properties
I have a confusion regarding datasource autoconfiguration in Spring-boot.我对 Spring-boot 中的数据源自动配置感到困惑。 From what I have read, we have to specify the datasource properties in the form spring.datasource.*
.根据我的阅读,我们必须以spring.datasource.*
的形式指定数据源属性。 But my application code works fine if I supply property name in the form SPRING_DATASOURCE_*
.但是,如果我以SPRING_DATASOURCE_*
形式提供属性名称,我的应用程序代码就可以正常工作。 Is there any reason that I am missing, due to which it works?有什么理由让我失踪,因为它有效吗? Please clarify.请说清楚。
I think You've come across a feature of spring boot called Relaxed Binding .我认为您已经遇到了 spring 引导的一项功能,称为Relaxed Binding 。
It allows using some "relaxed" rules for binding to ConfigurationProperties.它允许使用一些“宽松”的规则来绑定到 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 在这里你可以找到官方文档中相关章节的链接
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: Spring引导具有所谓的宽松绑定允许您以不同的方式定义配置:
The latter is often used when passed via environment variables.后者通常在通过环境变量传递时使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.