首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >spring-cloud-config-server -无法为主远程合并remote: null

spring-cloud-config-server -无法为主远程合并remote: null
EN

Stack Overflow用户
提问于 2020-04-06 01:40:20
回答 5查看 4.7K关注 0票数 5

我已经使用spring开发了配置服务器。

我的Application.java是

代码语言:javascript
运行
复制
@EnableConfigServer
@SpringBootApplication

public class SpringConfigServerApplication {

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

我的bootstrap.properties文件

代码语言:javascript
运行
复制
#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

我的配置-服务器-客户端开发.属性文件

代码语言:javascript
运行
复制
msg = Hello world - this is from config server – Development environment.

我已经使用git、git和git提交命令将我的文件添加到本地git。

但是当我运行这个应用程序并转到

它不显示我的财产价值。

代码语言:javascript
运行
复制
// 20200406064430
// http://localhost:8888/client-config/development

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

]
}

应用程序日志上写着:

代码语言:javascript
运行
复制
WARN 2125 --- [nio-8888-exec-2] .c.s.e.MultipleJGitEnvironmentRepository : Could not merge remote for master remote: null

我错过什么了吗?

我在用macOS

EN

回答 5

Stack Overflow用户

发布于 2020-07-21 18:54:45

当您将git指向本地目录时,需要使用本机配置文件运行服务器,在您的例子中是file://Users/dineth/Documents/MyProjects/sample-git-sources/config-server-repo

只需将以下行添加到Config application.properties

代码语言:javascript
运行
复制
spring.profiles.active=native
票数 9
EN

Stack Overflow用户

发布于 2020-08-25 17:43:35

我也犯了同样的“不能合并”错误。我改变了我的git.url,让它消失了。

我认为这里的主要问题是在配置服务启动后无法看到您的配置。我通过添加‘search-path:’属性和正确形成config-repo的组合来解决这个问题。

以下是我在bootstrap.yml中的配置:

代码语言:javascript
运行
复制
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}'

我的config-repo的结构如下:

代码语言:javascript
运行
复制
$ 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

配置找到:

代码语言:javascript
运行
复制
$ 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
EN

Stack Overflow用户

发布于 2021-09-15 16:47:44

我也有同样的问题。检查一下打印错误。在这种情况下,client-config/development应该与本地回购名称匹配。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61051779

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档