[英]Spring boot Cloud Embedding Config Server to get properties from Git repo for each request
I am using Spring Cloud Embedding Config Server to get the configuration from Git while server startup. 我正在使用Spring Cloud Embedding Config Server在服务器启动时从Git获取配置。 Its working fine.
它的工作正常。 Below is my config.
下面是我的配置。
bootstrap.properties bootstrap.properties
spring.application.name= "credentialInfo" spring.application.name =“ credentialInfo”
spring.cloud.config.server.bootstrap= "true" spring.cloud.config.server.bootstrap =“ true”
spring.cloud.config.server.git.uri= " https://11111@bitbucket.global.company.com/scm/~11111/spring-cloud-config.git " spring.cloud.config.server.git.uri =“ https://11111@bitbucket.global.company.com/scm/~11111/spring-cloud-config.git ”
spring.cloud.config.server.git.username= "aaaa" spring.cloud.config.server.git.username =“ aaaa”
spring.cloud.config.server.git.password= "bbbb" spring.cloud.config.server.git.password =“ bbbb”
Now I have to get the properties from Git repo for each request with username and password collected from Customers.How can I achieve this ..? 现在我必须从Git存储库中为每个请求获取属性,并使用从客户收集的用户名和密码。如何实现..?
通常,启动和调用“执行器/刷新”端点时,客户端应用程序通过配置服务器从git获取属性。
I'm that the requirement as you state its doesn't work well with Spring Boot. 我认为您所要求的要求不适用于Spring Boot。 When configurations are read (no matter from where, including the configuration service) they are used to configure spring beans during the startup.
读取配置时(无论从何处,包括配置服务),它们都将在启动期间用于配置spring bean。
For example, if you have a configuration of, say, db host, this configuration is supposed to be used by bean responsible for database connectivity (DataSource) 例如,如果您有一个例如db host的配置,则此配置应由负责数据库连接的bean使用(DataSource)
The point is that by the time that Application Context starts, beans are already configured. 关键是,到应用程序上下文启动时,就已经配置了bean。
Its true that some beans having refreashable scope define a custom logic to get "re-initialized" as a consequence of calling /refresh endpoint, but this is not what you're asking for (at least as far as I understood) 确实,某些具有可刷新范围的bean定义了自定义逻辑,以通过调用/ refresh端点来“重新初始化”,但这不是您要的(至少据我了解)
Instead you say, that the client does something during the application startup and this action should lead to beans change. 相反,您说的是,客户端在应用程序启动期间执行了某些操作,并且此操作应导致Bean更改。 This is potentially a very expensive operation and I don't think you should go in this direction.
这可能是一项非常昂贵的操作,我认为您不应该朝这个方向发展。 Usually beans are not re-created during runtime (of scope singleton, and the chances are that most of the beans are of this scope)
通常,在运行时不会重新创建Bean(范围是单例,并且大多数Bean都属于此范围)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.