首页 文章

使用Spring Cloud Config而不使用Git repo

提问于
浏览
20

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

UPDATE:

感谢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": []
}

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

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

4 回答

  • 10

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

    classpath:/configs
    
  • 21

    运行 spring.profiles.active=native . 有关详细信息,请参阅File System Backend . 您需要将 spring.cloud.config.server.native.searchLocations 设置为要查看的目录 .

  • 4

    对于 Windows 我使用它是这样的:

    spring.cloud.config.server.git.uri=C:\\\\Users\\\\my.user\\\\Desktop\\\\config\\\\
    
  • 0

    尝试在不指定文件名的情况下创建目录路径:

    文件:/// C:/用户/家庭/桌面/ yourProject /混帐回购

相关问题