我已经使用spring开发了配置服务器。
我的Application.java是
@EnableConfigServer
@SpringBootApplication
public class SpringConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(SpringConfigServerApplication.class, args);
}}
我的bootstrap.properties文件
#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
我的配置-服务器-客户端开发.属性文件
msg = Hello world - this is from config server – Development environment.
我已经使用git、git和git提交命令将我的文件添加到本地git。
但是当我运行这个应用程序并转到
它不显示我的财产价值。
// 20200406064430
// http://localhost:8888/client-config/development
{
"name": "client-config",
"profiles": [
"development"
],
"label": null,
"version": "4f989b109d1e6d77c8f44a664b275305ddddf014",
"state": null,
"propertySources": [
]
}
应用程序日志上写着:
WARN 2125 --- [nio-8888-exec-2] .c.s.e.MultipleJGitEnvironmentRepository : Could not merge remote for master remote: null
我错过什么了吗?
我在用macOS
发布于 2020-07-21 18:54:45
当您将git指向本地目录时,需要使用本机配置文件运行服务器,在您的例子中是file://Users/dineth/Documents/MyProjects/sample-git-sources/config-server-repo
只需将以下行添加到Config application.properties
spring.profiles.active=native
发布于 2020-08-25 17:43:35
我也犯了同样的“不能合并”错误。我改变了我的git.url,让它消失了。
我认为这里的主要问题是在配置服务启动后无法看到您的配置。我通过添加‘search-path:’属性和正确形成config-repo的组合来解决这个问题。
以下是我在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}'
我的config-repo的结构如下:
$ 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
配置找到:
$ 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"
}
}
]
}
发布于 2021-09-15 16:47:44
我也有同样的问题。检查一下打印错误。在这种情况下,client-config/development
应该与本地回购名称匹配。
https://stackoverflow.com/questions/61051779
复制相似问题