5
votes

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

3
can you post how your config repo looks like ? - Sikorski
on a second look, i noticed your property file name is config-server-client-development.properties. This is wrong, it should be app-env.properties so in your case it will be client-config-development.properties. - Sikorski

3 Answers

7
votes

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
0
votes

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"
      }
    }
  ]
}
0
votes

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