Warm tip: This article is reproduced from serverfault.com, please click

java-Spring Cloud Config服务器

(java - Spring Cloud Config Server)

发布于 2018-09-17 18:11:01

我在github repo中查看了许多spring cloud config服务器的代码,下面是作为属性文件的一部分提供的2个值。我相信为了连接到github的https端点,用户名和密码也是必需的。这些可能是环境变量的一部分吗?

server.port=7070
spring.cloud.config.server.git.uri=https://

编辑:

下面是我在 Spring 网站上看到的示例。但是,在我企业中的所有github仓库中,我都看不到设置的用户名和密码,因为它们是敏感信息。如果属性文件中未提供uid / pwd,如何设置或配置服务器访问github url?

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/spring-cloud-samples/config-repo
          username: trolley
          password: strongpassword
Questioner
Punter Vicky
Viewed
11
Se ven 2018-09-18 14:27:49
  1. 对于公共存储库,不需要使用用户名密码或其他授权来获取配置属性,因为需要专用存储库身份验证。
  2. 可以从os或java-system-property和命令行的环境中设置变量。优先级:命令行参数> java-system-property> os-env> application.properties

因此,例如,如果我设置属性直接使用命令行(优先级最高)该怎么办?例如:

java -jar config-server.jar --spring.cloud.config.server.git.username=xxx --spring.cloud.config.server.git.password=xxx

其中包含CI工具中的所有参数,或者由某人管理的所有参数,你都不会在源代码中看到它。