Which Git Strategy Works Best for Spring Cloud Config? Compare Two Approaches
This article compares two common Spring Cloud Config storage strategies—sharing a single Git repository with per‑project directories versus using a separate Git repository per project—detailing configuration properties, directory mapping, and the pros and cons of each approach.
Spring Cloud Config uses Git as its default storage backend, and many teams adopt this model. The article outlines two frequently used configuration strategies.
Strategy 1: Multiple projects share a single Git repository, using different directories
Key configuration properties:
spring.cloud.config.server.git.uri=https://github.com/dyc87112/config-repo.git spring.cloud.config.server.git.search-paths=/{application}In this mode, each project's spring.application.name (e.g., user-service) maps to a subdirectory ( /user-service) within the shared repository. Configuration files are stored as application-{profile}.properties, where {profile} represents the environment name.
Pros: Simple management when a single person maintains all configurations.
Cons: Weak permission control, making DevOps practices difficult.
Strategy 2: Each project uses its own Git repository
Key configuration property:
spring.cloud.config.server.git.uri=https://github.com/dyc87112/{application}.gitHere, the project name directly determines the repository URL (e.g., user-service maps to https://github.com/dyc87112/user-service.git). Configuration files follow the same application-{profile}.properties naming convention.
Pros: Better support for DevOps; using platforms like GitLab provides UI and fine‑grained permission management.
Cons: Managing many repositories can become cumbersome if the team does not follow a DevOps model.
Both strategies have trade‑offs, and the choice depends on team size, governance needs, and operational practices.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
