How to resolve Invalid config server configuration or NoRemoteRepositoryException with spring cloud config server
Problem
When starting a Spring Cloud Config Server that uses a local file system backend, you might encounter the following error:
Or this error:
These errors occur when the configuration for the Spring Cloud Config Server is incorrect, particularly when using a local file system as the backend.
Environment
- SpringBoot 2.3
- Spring Cloud Config Server 2.2.3.RELEASE
- SpringCloudVersion Hoxton.SR6
Configuration
To use a local directory as the config server’s repository, you might have configured the following:
Reason
The above configuration does not specify the config server’s profile. If you want to use a local file system directory as the config repository, you should use the native profile.
According to the official documentation:
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 withspring.profiles.active=native
.
Solution
To resolve the issue, update your configuration file to include the native
profile:
The key addition is the line:
This tells Spring Cloud Config Server to use the local file system as the backend, searching for config files in the directory specified by spring.cloud.config.server.native.search-locations
.
After updating the configuration, restart the Spring Cloud Config Server. You should see logs indicating that the server is using the native
profile and successfully loading property sources from the specified directory.
Summary
When using a local file system as the backend for Spring Cloud Config Server, it is crucial to specify the native
profile in your configuration. This ensures that the server searches for configuration files in the correct location and avoids errors related to missing Git repositories. By following the steps outlined in this post, you can resolve the “Invalid config server configuration” and “NoRemoteRepositoryException” errors effectively.
Final Words + More Resources
My intention with this article was to help others who might be considering solving such a problem. So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!