简体   繁体   English

Spring Boot Cloud Embedding Config Server为每个请求从Git存储库获取属性

[英]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.

相关问题 将 spring 云配置服务器连接到本地 git 存储库失败 - connecting spring cloud config server to local git repo failed 从 Spring 云配置服务器从 GIT 存储库获取文件名列表 - Getting list of file names from GIT repo from Spring cloud config server 在没有 Git 存储库的情况下使用 Spring Cloud Config - Using Spring Cloud Config without Git repo Spring Cloud Config Server还能将配置更新推送到远程git repo吗? - Can the Spring Cloud Config Server also push config updates to the remote git repo? 从Spring引导单元测试中排除Spring Cloud Config Server - Exclude Spring Cloud Config Server from Spring boot unit test Spring Cloud Config Server-设置克隆git repo的文件夹的目录 - Spring cloud config server -Set directory of folder where git repo are cloned 保存从Spring Cloud Config Server下载的属性 - Save Properties Downloaded from Spring Cloud Config Server Spring 云配置服务器未从 git 提取最新提交 - Spring cloud Config server not pulling latest commit from git 无法在 Spring 云配置服务器中从 GIT 读取属性源 - Unable to read property source from GIT in Spring cloud config server 如何从Spring Boot Config Server服务的其他属性文件中的application.properties获取密钥? - How can I get the keys from application.properties within other properties files served by Spring Boot Config Server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM