Spring Cloud git configuration -- placing repository in folder directly containing the classpath?
Solution 1
From the documentation:
https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html
2.1.3 File System Backend: There is also a “native” profile in the Config Server that does not use Git but loads the config files from the local classpath or file system (any static URL you want to point to with spring.cloud.config.server.native.searchLocations). To use the native profile, launch the Config Server with spring.profiles.active=native.
So, in your case, it would be:
spring.profiles.active=native
spring.cloud.config.server.native:searchLocations=file://${user.dir}/cloud-configuration-repository
Solution 2
I had the exact same problem that @Nuradin was having, and the problem was that I had added the spring.cloud.config.server.git.uri property in the wrong file. I needed to add that line to the application.properties files instead of my service.properties file. Here's what my application.properties file now looks like:
spring.application.name=spring-cloud-config-server
server.port=8888
spring.cloud.config.server.git.uri: file://${user.home}/cloud-git-repo
I'm using Spring Tool Suite on Windows 10.
Nuradin
Updated on June 04, 2022Comments
-
Nuradin almost 2 years
I want to place the git repository in a folder directly above the classpath during the development stage of an application.
Currently, I have this as my Spring Cloud git URI:
spring.cloud.config.server.git.uri=file://${user.dir}/cloud-configuration-repository
This URI points to a folder directly above the classpath.
I get this error, however, during runtime.
*************************** APPLICATION FAILED TO START *************************** Description: Invalid config server configuration. Action: If you are using the git profile, you need to set a Git URI in your configuration. If you are using a native profile and have spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
Edit: here is the project structure that I wish to have:
Project ├── _.idea ├── src | ├── main | └── test ├── target └── cloud-configuration-repository
-
Nuradin over 5 yearsWhat if I wanted to have my config folder as a Git subrepository of my Git project? I'll put the structure as an edit in the OP
-
Pradip Karki over 5 yearsthen it should be fine to use
spring.cloud.config.server.git.uri
withgit uri
-
Nuradin almost 5 yearsYes! This is what I ended up having to do.