'spring-cloud-config-server - Could not merge remote for master remote: null

I have developed config server using spring.

My Application.java is

@EnableConfigServer
@SpringBootApplication

public class SpringConfigServerApplication {

public static void main(String[] args) {
    SpringApplication.run(SpringConfigServerApplication.class, args);
}}

My bootstrap.properties file

#Server port
server.port = 8888

#Git repo location
spring.cloud.config.server.git.uri=file://Users/dineth/Documents/MyProjects/sample-git-sources/config-server-repo

My config-server-client-development.properties file

msg = Hello world - this is from config server – Development environment.

I have tiggered git init, git add and git commit commands to add my file to local git.

But when I run the app and go to http://localhost:8888/client-config/development

It does not show my property value.

// 20200406064430
// http://localhost:8888/client-config/development

{
"name": "client-config",
"profiles": [
"development"
],
"label": null,
"version": "4f989b109d1e6d77c8f44a664b275305ddddf014",
"state": null,
"propertySources": [

]
}

And Application log says:

WARN 2125 --- [nio-8888-exec-2] .c.s.e.MultipleJGitEnvironmentRepository : Could not merge remote for master remote: null

Did I miss anything?

I'm using macOS



Solution 1:[1]

You need to run Config Server using the native profile when pointing your git repo to a local directory, in your case file://Users/dineth/Documents/MyProjects/sample-git-sources/config-server-repo

Just add the following line to the Config Server application.properties:

spring.profiles.active=native

Solution 2:[2]

I had this same 'Could not merge' error. I got it to go away by changing my git.url.

I think the main issue here was not being able to see your config after config-service started up. I solved this by a combination of adding the 'search-paths:' attribute, and forming my config-repo correctly.

Here is my config, in bootstrap.yml:

spring:
  application:
    name: config-service
  cloud:
    config:
      server:
        git:
          # Spring redefines ${variable} to be @variable@ for maven vars as it uses ${...} for itself
          uri: @project.basedir@/../config-repo
          #uri: ${user.home}\projects\java\prototype0\config-repo # works
          #uri: C:\Users\myuser\projects\java\prototype0\config-repo # works
          #uri: file:///C:\Users\myuser\projects\java\prototype0\config-repo # works, but gives Could not merge error
          #uri: file:///C:/Users/myuser/projects/java/prototype0/config-repo # works, but gives Could not merge error
          basedir: config_repo
          clone-on-start: true
          search-paths: '{application}'

My config-repo is structured as so:

$ find config-repo/ | grep -v git
config-repo/
config-repo/admin-service
config-repo/admin-service/admin-service-dev.yml
config-repo/eureka-service
config-repo/eureka-service/eureka-service-dev.yml
config-repo/gateway-service
config-repo/gateway-service/gateway-service-dev.yml
config-repo/resource1-service
config-repo/resource1-service/resource1-service-dev.yml

Config found:

$ curl http://localhost:8762/eureka-service/dev | jq

{
  "name": "eureka-service",
  "profiles": [
    "dev"
  ],
  "label": null,
  "version": "4fb2d62fe542d8f2c73ae422d5266874cbfc779a",
  "state": null,
  "propertySources": [
    {
      "name": "C:/Users/myuser/projects/java/prototype0/config-service/../config-repo/eureka-service/eureka-service-dev.yml",
      "source": {
        "management.endpoints.web.exposure.include": "*",
        "management.endpoint.health.show-details": "ALWAYS"
      }
    }
  ]
}

Solution 3:[3]

I had same issue. Check the typo. In this case client-config/development should be match with your local repo name.

Solution 4:[4]

I have similar issue with Git version 2.27 (by default use branch name master) on Window and Spring boot 2.6.3 (by default look for branch name main). I updated my git version and recreated the local git repo and the problem got fixed.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dbaltor
Solution 2
Solution 3 Jayod Kavinda
Solution 4 AkDev