39
votes

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!

7

7 Answers

18
votes

You could try changing the search path to the following

classpath:/configs
35
votes

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.

14
votes

For Windows I used it like this:

spring.cloud.config.server.git.uri=C:\\\\Users\\\\my.user\\\\Desktop\\\\config\\\\
2
votes

try to make your path to the directory without specifying the name of the file:

file:///C:/Users/home/Desktop/yourProject/git-repo

1
votes

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
1
votes

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 
0
votes

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