Is it possible to use Spring Cloud Config without using any Git repo at all? I'm trying to test it with a local directory with this in application.properties:
spring.cloud.config.server.git.uri=file://${user.dir}/src/main/resources/config-repo
But I get the following error:
java.lang.IllegalStateException: No .git at file://path/to/src/main/resources/config-repo
So is it not possible to use Spring Cloud if one is not using Git at all?
UPDATE:
Thanks to Spencer's advice, I added the following:
spring.profiles.active=native spring.cloud.config.server.native.searchLocations=${user.dir}/src/main/resources/configs
And I have a file "bar.properties" inside "configs" with the following contents:
foo: bar
But the response I get is not reading the file:
{
"name": "bar",
"profiles": [
"default"
],
"label": "master",
"propertySources": []
}
The URL I'm using is http://localhost:8888/bar/default
Am I missing something else? Thanks again in advance!
Run with spring.profiles.active=native
. See the File System Backend for more details. You'll want to set spring.cloud.config.server.native.searchLocations
to the dirs you want to look at.
您可以尝试将搜索路径更改为以下内容
classpath:/configs
对于Windows,我是这样使用的:
spring.cloud.config.server.git.uri=C:\\\\Users\\\\my.user\\\\Desktop\\\\config\\\\
try to make your path to the directory without specifying the name of the file:
file:///C:/Users/home/Desktop/yourProject/git-repo
You can try this following ways:
file:\\C:/WORKSPACE/GIT/repo
file:///C:/microservices/repo
file:///C:/Users/test/Documents/workspace-sts-3.9.4.RELEASE/repo
file:\\C:/Users/test/Documents/workspace-sts-3.9.4.RELEASE/repo
Please follow the below mentioned configurations
Here is the Reference
https://cloud.spring.io/spring-cloud-config/reference/html/#_spring_cloud_config_server
# Working - in Windows
spring.cloud.config.server.git.uri=file:/C:/git-repo
spring.cloud.config.server.git.uri=file:///C:/git-repo
spring.cloud.config.server.git.uri=C:\\\\git-repo
#Not Working - in Windows
#spring.cloud.config.server.git.uri=file:///C:\git-repo
I used the same mentioned format file:///C:/Users/home/Desktop/yourProject/git-repo and it worked for me. I am using windows system.
This worked for Windows (I created a config folder in /Desktop):
spring.cloud.config.server.git.uri=file:///${user.home}/Desktop/config
The following didn't work so I used above:
spring.cloud.config.server.git.uri=file://${HOME}/Desktop/config
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.