gpt4 book ai didi

java - 在没有 Git 存储库的情况下使用 Spring Cloud Config

转载 作者:IT老高 更新时间:2023-10-28 13:46:21 26 4
gpt4 key购买 nike

是否可以在不使用任何 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

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

{
"name": "bar",
"profiles": [
"default"
],
"label": "master",
"propertySources": []
}

我使用的网址是 http://localhost:8888/bar/default

我还缺少其他东西吗?再次提前感谢!

最佳答案

使用 spring.profiles.active=native 运行。见 File System Backend更多细节。您需要将 spring.cloud.config.server.native.searchLocations 设置为您要查看的目录。

关于java - 在没有 Git 存储库的情况下使用 Spring Cloud Config,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33178448/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com