使用Spring Cloud Config而不使用Git repo

Tur*_*rar 27 java spring spring-cloud spring-cloud-config

是否可以在不使用任何Git仓库的情况下使用Spring Cloud Config?我正在尝试使用application.properties中的本地目录来测试它:

spring.cloud.config.server.git.uri=file://${user.dir}/src/main/resources/config-repo

但是我收到以下错误:

java.lang.IllegalStateException:文件中没有.git:// path/to/src/main/resources/config-repo

如果一个人根本不使用Git,那么就不可能使用Spring Cloud吗?

更新:

感谢Spencer的建议,我补充了以下内容:

spring.profiles.active=native spring.cloud.config.server.native.searchLocations=${user.dir}/src/main/resources/configs

我在"configs"中有一个文件"bar.properties",其中包含以下内容:

foo: bar
Run Code Online (Sandbox Code Playgroud)

但我得到的反应不是读取文件:

{
  "name": "bar",
  "profiles": [
    "default"
  ],
  "label": "master",
  "propertySources": []
}
Run Code Online (Sandbox Code Playgroud)

我正在使用的URL是http:// localhost:8888/bar/default

我错过了别的什么吗?再次感谢您!

spe*_*ibb 26

运行spring.profiles.active=native.有关更多详细信息,请参阅文件系统后端.你想要设置spring.cloud.config.server.native.searchLocations你想看的目标.

  • 从头开始,这就是我需要的:“spring.profiles.active=native”和“spring.cloud.config.server.native.searchLocations=C:/Users/MyUser/Documents/config” (2认同)

use*_*753 12

您可以尝试将搜索路径更改为以下内容

classpath:/configs
Run Code Online (Sandbox Code Playgroud)


小智 8

对于Windows,我像这样使用它:

spring.cloud.config.server.git.uri=C:\\\\Users\\\\my.user\\\\Desktop\\\\config\\\\
Run Code Online (Sandbox Code Playgroud)

  • 真的吗?它仅在 config 是 git repo 并且其文件已提交时才有效。否则,配置服务器将看不到 yml/properties 文件(使用 Camden.SR5)。 (2认同)