43

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!

pramodc84
  • 1,576
  • 2
  • 25
  • 33
Turar
  • 1,511
  • 5
  • 17
  • 27

8 Answers8

36

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.

spencergibb
  • 24,471
  • 6
  • 69
  • 75
  • 1
    For anyone using a Windows path (maybe, like me, you're going through the Spring Cloud tutorial on your workstation), I found that I needed the "spring.profiles.active=native" property and the git URI using this format: "spring.cloud.config.server.git.uri = file:///C:/Users/MyUser/Documents/config" – jpappe May 29 '18 at 16:02
  • 2
    Scratch that, this is what I needed: "spring.profiles.active=native" and "spring.cloud.config.server.native.searchLocations=C:/Users/MyUser/Documents/config" – jpappe Jun 14 '18 at 12:46
18

You could try changing the search path to the following

classpath:/configs
user1107753
  • 1,566
  • 4
  • 24
  • 36
14

For Windows I used it like this:

spring.cloud.config.server.git.uri=C:\\\\Users\\\\my.user\\\\Desktop\\\\config\\\\
Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108
Horatiu
  • 375
  • 3
  • 6
  • 2
    Really? It only worked when config is a git repo and its files are committed. Otherwise, the config server would not see the yml/properties files (using Camden.SR5). – syr Jul 27 '17 at 10:12
  • Ya this doesn't work unless that directory is a git repo – prettyvoid Mar 26 '18 at 14:14
  • 1
    For windows without git; this worked for me: `spring.cloud.config.server.native.searchLocations=file:/C:/toybox-config-server-repo/` (1.5.10.RELEASE) – Murat Aykanat May 06 '18 at 10:37
2

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

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

  • file:/// (note 3 forward slashes as opposed to 2 which was the case with original question - did the trick for me!) – JavaTec Nov 06 '18 at 18:38
2

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
Werner Henze
  • 16,404
  • 12
  • 44
  • 69
Ganesh Giri
  • 1,135
  • 11
  • 18
2

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 
Lova Chittumuri
  • 2,994
  • 1
  • 30
  • 33
0

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
sy456
  • 1,644
  • 2
  • 14
  • 16
0

I had the same problem and I use this :

spring.cloud.config.server.git.uri=file:///G:/software installed ssd/intelij/spring-boot-project/microservice-with-config-server/git

the "git" is the name of my folder I put my file "limits-service.properties"

Also check the git local branch, be the "main" not "master", If not, change it to the main. After all check the properties are set are the same name, I made all this mistake, so I hope it is helpfull for the other people.thanks