2015-10-16 78 views
8

根本沒有使用任何Git倉庫,可以使用Spring Cloud Config嗎?我試圖用本地目錄與這application.properties測試:在不使用Git倉庫的情況下使用Spring Cloud Config

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:

由於斯賓塞的建議,我增加了以下內容:

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

而且我有一個文件 「bar.properties」 內部 「CONFIGS」 具有以下內容:

foo: bar 

但我得到的迴應是不讀取文件:

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

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

我失去了什麼東西?提前再次感謝!

回答

4

你可以嘗試改變搜索路徑以下

classpath:/configs 
+0

謝謝,成功了! – Turar

10

spring.profiles.active=native運行。有關更多詳細信息,請參見File System Backend。您需要將spring.cloud.config.server.native.searchLocations設置爲您要查看的目標。

3

對於的Windows我用這樣的:

spring.cloud.config.server.git.uri=C:\\\\Users\\\\my.user\\\\Desktop\\\\config\\\\ 
+1

真的嗎?它只有當config是一個git repo並且它的文件被提交時才起作用。否則,配置服務器不會看到yml/properties文件(使用Camden.SR5)。 –

相關問題