Reputation: 1561
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!
Upvotes: 45
Views: 37500
Reputation: 111
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
Upvotes: 0
Reputation: 1704
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
Upvotes: 0
Reputation: 3323
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
Upvotes: 2
Reputation: 1161
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
Upvotes: 2
Reputation: 31
try to make your path to the directory without specifying the name of the file:
file:///C:/Users/home/Desktop/yourProject/git-repo
Upvotes: 2
Reputation: 385
For Windows I used it like this:
spring.cloud.config.server.git.uri=C:\\\\Users\\\\my.user\\\\Desktop\\\\config\\\\
Upvotes: 14
Reputation: 1646
You could try changing the search path to the following
classpath:/configs
Upvotes: 18
Reputation: 25177
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.
Upvotes: 37